commit 4d4fcbb13be899c0547a8f2b4f35fa1611027ea7
parent 33844f242e53e50e1dde2a0258e4faa303ccf423
Author: Emilio Cobos Álvarez <emilio@crisal.io>
Date: Sat, 22 Nov 2025 16:53:17 +0000
Bug 1998621 - Use a quoted string for view transition dynamic animation names. r=view-transitions-reviewers,boris
Fix a quoting issue that is exposed by japanese-tag.html
The quoting issue got introduced by bug 1986533 which converted this
code to work on UTF-8 strings rather than utf-16.
Differential Revision: https://phabricator.services.mozilla.com/D271850
Diffstat:
5 files changed, 19 insertions(+), 25 deletions(-)
diff --git a/dom/view-transitions/ViewTransition.cpp b/dom/view-transitions/ViewTransition.cpp
@@ -889,9 +889,11 @@ void ViewTransition::SetupTransitionPseudoElements() {
// If both of capturedElement's old image and new element are not null,
// then:
if (capturedElement.mOldState.mTriedImage && capturedElement.mNewElement) {
- NS_ConvertUTF16toUTF8 dynamicAnimationName(
- kGroupAnimPrefix + nsDependentAtomString(transitionName));
-
+ nsAutoCString dynamicAnimationName;
+ nsStyleUtil::AppendQuotedCSString(
+ NS_ConvertUTF16toUTF8(kGroupAnimPrefix +
+ nsDependentAtomString(transitionName)),
+ dynamicAnimationName);
capturedElement.mGroupKeyframes =
BuildGroupKeyframes(mDocument, capturedElement.mOldState.mTransform,
capturedElement.mOldState.mBorderBoxSize,
diff --git a/layout/style/FontFaceImpl.cpp b/layout/style/FontFaceImpl.cpp
@@ -451,7 +451,7 @@ bool FontFaceImpl::SetDescriptor(nsCSSFontDesc aFontDesc,
if (aFontDesc == eCSSFontDesc_Family) {
// TODO: Warn to the console?
nsAutoCString quoted;
- nsStyleUtil::AppendEscapedCSSString(aValue, quoted, '"');
+ nsStyleUtil::AppendQuotedCSSString(aValue, quoted, '"');
if (Servo_FontFaceRule_SetDescriptor(GetData(), aFontDesc, "ed, url,
&changed)) {
return true;
diff --git a/layout/style/nsStyleUtil.cpp b/layout/style/nsStyleUtil.cpp
@@ -139,8 +139,8 @@ bool nsStyleUtil::ValueIncludes(const nsAString& aValueList,
return false;
}
-void nsStyleUtil::AppendEscapedCSSString(const nsACString& aString,
- nsACString& aReturn, char aQuoteChar) {
+void nsStyleUtil::AppendQuotedCSSString(const nsACString& aString,
+ nsACString& aReturn, char aQuoteChar) {
MOZ_ASSERT(aQuoteChar == '\'' || aQuoteChar == '"',
"CSS strings must be quoted with ' or \"");
@@ -149,19 +149,14 @@ void nsStyleUtil::AppendEscapedCSSString(const nsACString& aString,
const char* in = aString.BeginReading();
const char* const end = aString.EndReading();
for (; in != end; in++) {
- if (*in < 0x20 || *in == 0x7F) {
- // Escape U+0000 through U+001F and U+007F numerically.
- aReturn.AppendPrintf("\\%x ", *in);
- } else {
- if (*in == '"' || *in == '\'' || *in == '\\') {
- // Escape backslash and quote characters symbolically.
- // It's not technically necessary to escape the quote
- // character that isn't being used to delimit the string,
- // but we do it anyway because that makes testing simpler.
- aReturn.Append('\\');
- }
- aReturn.Append(*in);
+ if (*in == '\\' || *in == aQuoteChar) {
+ // Escape backslash and quote characters symbolically.
+ // It's not technically necessary to escape the quote
+ // character that isn't being used to delimit the string,
+ // but we do it anyway because that makes testing simpler.
+ aReturn.Append('\\');
}
+ aReturn.Append(*in);
}
aReturn.Append(aQuoteChar);
}
diff --git a/layout/style/nsStyleUtil.h b/layout/style/nsStyleUtil.h
@@ -43,11 +43,10 @@ class nsStyleUtil {
const nsAString& aValue,
const nsStringComparator& aComparator);
- // Append a quoted (with 'quoteChar') and escaped version of aString
- // to aResult. 'aQuoteChar' must be ' or ".
- static void AppendEscapedCSSString(const nsACString& aString,
- nsACString& aResult,
- char aQuoteChar = '"');
+ // Append a quoted (with 'quoteChar') version of aString to aResult.
+ // 'aQuoteChar' must be ' or ".
+ static void AppendQuotedCSString(const nsACString& aString,
+ nsACString& aResult, char aQuoteChar = '"');
// Append the identifier given by |aIdent| to |aResult|, with
// appropriate escaping so that it can be reparsed to the same
diff --git a/testing/web-platform/meta/css/css-view-transitions/escaped-name.html.ini b/testing/web-platform/meta/css/css-view-transitions/escaped-name.html.ini
@@ -1,2 +0,0 @@
-[escaped-name.html]
- expected: FAIL