From 854010bc34484a22f5e97ed21ea76e76cde6a9ca Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Tue, 11 Jun 2024 18:46:30 +0200 Subject: Merging upstream version 1.62.1. Signed-off-by: Daniel Baumann --- src/HtmlParser.cc | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/HtmlParser.cc') diff --git a/src/HtmlParser.cc b/src/HtmlParser.cc index 591c4c7..a420c93 100644 --- a/src/HtmlParser.cc +++ b/src/HtmlParser.cc @@ -58,11 +58,11 @@ StringRef get_attr(const xmlChar **attrs, const StringRef &name) { namespace { ResourceType get_resource_type_for_preload_as(const StringRef &attribute_value) { - if (util::strieq_l("image", attribute_value)) { + if (util::strieq("image"_sr, attribute_value)) { return REQ_IMG; - } else if (util::strieq_l("style", attribute_value)) { + } else if (util::strieq("style"_sr, attribute_value)) { return REQ_CSS; - } else if (util::strieq_l("script", attribute_value)) { + } else if (util::strieq("script"_sr, attribute_value)) { return REQ_UNBLOCK_JS; } else { return REQ_OTHERS; @@ -74,7 +74,7 @@ namespace { void add_link(ParserData *parser_data, const StringRef &uri, ResourceType res_type) { auto u = xmlBuildURI( - reinterpret_cast(uri.c_str()), + reinterpret_cast(uri.data()), reinterpret_cast(parser_data->base_uri.c_str())); if (u) { parser_data->links.push_back( @@ -90,35 +90,35 @@ void start_element_func(void *user_data, const xmlChar *src_name, auto parser_data = static_cast(user_data); auto name = StringRef{src_name, strlen(reinterpret_cast(src_name))}; - if (util::strieq_l("head", name)) { + if (util::strieq("head"_sr, name)) { ++parser_data->inside_head; } - if (util::strieq_l("link", name)) { - auto rel_attr = get_attr(attrs, StringRef::from_lit("rel")); - auto href_attr = get_attr(attrs, StringRef::from_lit("href")); + if (util::strieq("link"_sr, name)) { + auto rel_attr = get_attr(attrs, "rel"_sr); + auto href_attr = get_attr(attrs, "href"_sr); if (rel_attr.empty() || href_attr.empty()) { return; } - if (util::strieq_l("shortcut icon", rel_attr)) { + if (util::strieq("shortcut icon"_sr, rel_attr)) { add_link(parser_data, href_attr, REQ_OTHERS); - } else if (util::strieq_l("stylesheet", rel_attr)) { + } else if (util::strieq("stylesheet"_sr, rel_attr)) { add_link(parser_data, href_attr, REQ_CSS); - } else if (util::strieq_l("preload", rel_attr)) { - auto as_attr = get_attr(attrs, StringRef::from_lit("as")); + } else if (util::strieq("preload"_sr, rel_attr)) { + auto as_attr = get_attr(attrs, "as"_sr); if (as_attr.empty()) { return; } add_link(parser_data, href_attr, get_resource_type_for_preload_as(as_attr)); } - } else if (util::strieq_l("img", name)) { - auto src_attr = get_attr(attrs, StringRef::from_lit("src")); + } else if (util::strieq("img"_sr, name)) { + auto src_attr = get_attr(attrs, "src"_sr); if (src_attr.empty()) { return; } add_link(parser_data, src_attr, REQ_IMG); - } else if (util::strieq_l("script", name)) { - auto src_attr = get_attr(attrs, StringRef::from_lit("src")); + } else if (util::strieq("script"_sr, name)) { + auto src_attr = get_attr(attrs, "src"_sr); if (src_attr.empty()) { return; } @@ -134,8 +134,8 @@ void start_element_func(void *user_data, const xmlChar *src_name, namespace { void end_element_func(void *user_data, const xmlChar *name) { auto parser_data = static_cast(user_data); - if (util::strieq_l( - "head", + if (util::strieq( + "head"_sr, StringRef{name, strlen(reinterpret_cast(name))})) { --parser_data->inside_head; } -- cgit v1.2.3