Skip to content

Commit

Permalink
Support ignoring charset when parsing URLs in CSS behind a flag
Browse files Browse the repository at this point in the history
This is to allow testing of the desired behavior, and it's a possible
cause of an issue being discussed in Sass:
sass/dart-sass#568

There are two call sites for CSSParserContext::Charset(), one for the
regular parsing path, and one for parsing registered property values.
Rather than touching both, just throw away the charset override when the
feature is enabled.

Bug: 1485525

Change-Id: I3da69b4156d6a84bcc8e0517c954a79b522a9ec9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4846986
Commit-Queue: Philip Jägenstedt <foolip@chromium.org>
Reviewed-by: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1200109}
  • Loading branch information
foolip authored and Chromium LUCI CQ committed Sep 22, 2023
1 parent 16bc0ea commit d9ae032
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "third_party/blink/renderer/core/loader/document_loader.h"
#include "third_party/blink/renderer/core/page/page.h"
#include "third_party/blink/renderer/core/permissions_policy/layout_animations_policy.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"

namespace blink {

Expand Down Expand Up @@ -175,9 +176,12 @@ CSSParserContext::CSSParserContext(
use_legacy_background_size_shorthand_behavior_(
use_legacy_background_size_shorthand_behavior),
secure_context_mode_(secure_context_mode),
charset_(charset),
document_(use_counter_document),
resource_fetch_restriction_(resource_fetch_restriction) {}
resource_fetch_restriction_(resource_fetch_restriction) {
if (!RuntimeEnabledFeatures::CSSParserIgnoreCharsetForURLsEnabled()) {
charset_ = charset;
}
}

bool CSSParserContext::operator==(const CSSParserContext& other) const {
return base_url_ == other.base_url_ && origin_clean_ == other.origin_clean_ &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
default: "",
},

// Specifiy the default value of the base::Feature instance. This field
// Specify the default value of the base::Feature instance. This field
// works only if base_feature is not "none".
// If the field is missing or "", the default value depends on the 'status'
// field. See the comment above.
Expand Down Expand Up @@ -1034,6 +1034,11 @@
status: "stable",
base_feature: "CssPaintingForSpellingGrammarErrors",
},
{
// Ignore the stylesheet encoding when parsing URLs, always using UTF-8.
// See crbug.com/1485525.
name: "CSSParserIgnoreCharsetForURLs",
},
{
// crbug.com/1443291: Phrase Line Breaking
name: "CSSPhraseLineBreak",
Expand Down

0 comments on commit d9ae032

Please sign in to comment.