mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1008719. CSS syntax got changed to allow identifiers starting with "--", so update our escaping code accordingly. r=dholbert
This commit is contained in:
parent
153192ed49
commit
40a5bc161e
@ -81,13 +81,16 @@ void nsStyleUtil::AppendEscapedCSSString(const nsAString& aString,
|
|||||||
nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
||||||
{
|
{
|
||||||
// The relevant parts of the CSS grammar are:
|
// The relevant parts of the CSS grammar are:
|
||||||
// ident [-]?{nmstart}{nmchar}*
|
// ident ([-]?{nmstart}|[-][-]){nmchar}*
|
||||||
// nmstart [_a-z]|{nonascii}|{escape}
|
// nmstart [_a-z]|{nonascii}|{escape}
|
||||||
// nmchar [_a-z0-9-]|{nonascii}|{escape}
|
// nmchar [_a-z0-9-]|{nonascii}|{escape}
|
||||||
// nonascii [^\0-\177]
|
// nonascii [^\0-\177]
|
||||||
// escape {unicode}|\\[^\n\r\f0-9a-f]
|
// escape {unicode}|\\[^\n\r\f0-9a-f]
|
||||||
// unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
|
// unicode \\[0-9a-f]{1,6}(\r\n|[ \n\r\t\f])?
|
||||||
// from http://www.w3.org/TR/CSS21/syndata.html#tokenization
|
// from http://www.w3.org/TR/CSS21/syndata.html#tokenization but
|
||||||
|
// modified for idents by
|
||||||
|
// http://dev.w3.org/csswg/cssom/#serialize-an-identifier and
|
||||||
|
// http://dev.w3.org/csswg/css-syntax/#would-start-an-identifier
|
||||||
|
|
||||||
const char16_t* in = aIdent.BeginReading();
|
const char16_t* in = aIdent.BeginReading();
|
||||||
const char16_t* const end = aIdent.EndReading();
|
const char16_t* const end = aIdent.EndReading();
|
||||||
@ -97,7 +100,13 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
|||||||
|
|
||||||
// A leading dash does not need to be escaped as long as it is not the
|
// A leading dash does not need to be escaped as long as it is not the
|
||||||
// *only* character in the identifier.
|
// *only* character in the identifier.
|
||||||
if (in + 1 != end && *in == '-') {
|
if (*in == '-') {
|
||||||
|
if (in + 1 == end) {
|
||||||
|
aReturn.Append(char16_t('\\'));
|
||||||
|
aReturn.Append(char16_t('-'));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
aReturn.Append(char16_t('-'));
|
aReturn.Append(char16_t('-'));
|
||||||
++in;
|
++in;
|
||||||
}
|
}
|
||||||
@ -105,16 +114,8 @@ nsStyleUtil::AppendEscapedCSSIdent(const nsAString& aIdent, nsAString& aReturn)
|
|||||||
// Escape a digit at the start (including after a dash),
|
// Escape a digit at the start (including after a dash),
|
||||||
// numerically. If we didn't escape it numerically, it would get
|
// numerically. If we didn't escape it numerically, it would get
|
||||||
// interpreted as a numeric escape for the wrong character.
|
// interpreted as a numeric escape for the wrong character.
|
||||||
// A second dash immediately after a leading dash must also be
|
if (in != end && ('0' <= *in && *in <= '9')) {
|
||||||
// escaped, but this may be done symbolically.
|
aReturn.AppendPrintf("\\%hX ", *in);
|
||||||
if (in != end && (*in == '-' ||
|
|
||||||
('0' <= *in && *in <= '9'))) {
|
|
||||||
if (*in == '-') {
|
|
||||||
aReturn.Append(char16_t('\\'));
|
|
||||||
aReturn.Append(char16_t('-'));
|
|
||||||
} else {
|
|
||||||
aReturn.AppendPrintf("\\%hX ", *in);
|
|
||||||
}
|
|
||||||
++in;
|
++in;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ is(CSS.escape('-7a'), '-\\37 a', "escapingFailed Char: -7a");
|
|||||||
is(CSS.escape('-8a'), '-\\38 a', "escapingFailed Char: -8a");
|
is(CSS.escape('-8a'), '-\\38 a', "escapingFailed Char: -8a");
|
||||||
is(CSS.escape('-9a'), '-\\39 a', "escapingFailed Char: -9a");
|
is(CSS.escape('-9a'), '-\\39 a', "escapingFailed Char: -9a");
|
||||||
|
|
||||||
is(CSS.escape('--a'), '-\\-a', "escapingFailed Char: --a");
|
is(CSS.escape('--a'), '--a', 'Should not need to escape leading "--"');
|
||||||
|
|
||||||
is(CSS.escape('\x80\x2D\x5F\xA9'), '\\80 \x2D\x5F\xA9', "escapingFailed Char: \\x80\\x2D\\x5F\\xA9");
|
is(CSS.escape('\x80\x2D\x5F\xA9'), '\\80 \x2D\x5F\xA9', "escapingFailed Char: \\x80\\x2D\\x5F\\xA9");
|
||||||
is(CSS.escape('\xA0\xA1\xA2'), '\xA0\xA1\xA2', "escapingFailed Char: \\xA0\\xA1\\xA2");
|
is(CSS.escape('\xA0\xA1\xA2'), '\xA0\xA1\xA2', "escapingFailed Char: \\xA0\\xA1\\xA2");
|
||||||
|
@ -74,7 +74,7 @@ const substitutions = [
|
|||||||
{ t: "\\37 ", i: "\\37 ", s: "7" },
|
{ t: "\\37 ", i: "\\37 ", s: "7" },
|
||||||
{ t: "\\38 ", i: "\\38 ", s: "8" },
|
{ t: "\\38 ", i: "\\38 ", s: "8" },
|
||||||
{ t: "\\39 ", i: "\\39 ", s: "9" },
|
{ t: "\\39 ", i: "\\39 ", s: "9" },
|
||||||
{ t: "-\\-", i: "-\\-", s: "--" },
|
{ t: "-\\-", i: "--", s: "--" },
|
||||||
{ t: "-\\30 ", i: "-\\30 ", s: "-0" },
|
{ t: "-\\30 ", i: "-\\30 ", s: "-0" },
|
||||||
{ t: "-\\31 ", i: "-\\31 ", s: "-1" },
|
{ t: "-\\31 ", i: "-\\31 ", s: "-1" },
|
||||||
{ t: "-\\32 ", i: "-\\32 ", s: "-2" },
|
{ t: "-\\32 ", i: "-\\32 ", s: "-2" },
|
||||||
|
Loading…
Reference in New Issue
Block a user