Truly independent web browser
LibWeb: Keep quotes that are part of view-source attribute values
Andreas Klinga215a8420612
diff --git a/Libraries/LibWeb/Loader/SourceHighlighter.cpp b/Libraries/LibWeb/Loader/SourceHighlighter.cppindex 2f33bf3b189..dd813f93d08 100644--- a/Libraries/LibWeb/Loader/SourceHighlighter.cpp+++ b/Libraries/LibWeb/Loader/SourceHighlighter.cpp@@ -280,9 +280,18 @@ String SourceHighlighterClient::to_html_string(Optional<URL::URL> const& url, URif (!linkify_attribute)return {};- auto attribute_url_without_quotes = attribute_value.as_string().trim("\""sv);+ // NB: Only a leading quote starts a quoted value. Quotes elsewhere in an unquoted value are part of the value.+ auto attribute_url = attribute_value.as_string();+ if (attribute_url.starts_with('"') || attribute_url.starts_with('\'')) {+ // NB: A quoted value that spans several lines reaches us one line at a time, so do not link any part of it.+ if (attribute_url.length() < 2 || attribute_url[attribute_url.length() - 1] != attribute_url[0]) {+ linkify_attribute = false;+ return {};+ }+ attribute_url = attribute_url.substring_view(1, attribute_url.length() - 2);+ }- return Web::DOMURL::parse(attribute_url_without_quotes, base_url);+ return Web::DOMURL::parse(attribute_url, base_url);};size_t span_index = 0;