From d56e53788283738c6d40cd9ba68c26621b983bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Sun, 2 Sep 2018 22:54:57 +0000 Subject: [PATCH] style: Use proper escaping for pseudo-class strings. We always serialize as an atom, which is the previous behavior (though previous code was using string escaping which I think was not totally sound either...). Differential Revision: https://phabricator.services.mozilla.com/D4753 --- components/style/gecko/selector_parser.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index dcdb06e466a..32a7b1f6ad0 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -21,6 +21,7 @@ use str::starts_with_ignore_ascii_case; use string_cache::{Atom, Namespace, WeakAtom, WeakNamespace}; use style_traits::{CssWriter, ParseError, StyleParseErrorKind, ToCss as ToCss_}; use thin_slice::ThinBoxedSlice; +use values::serialize_atom_identifier; pub use gecko::pseudo_element::{PseudoElement, EAGER_PSEUDOS, EAGER_PSEUDO_COUNT, PSEUDO_COUNT}; pub use gecko::snapshot::SnapshotMap; @@ -78,7 +79,9 @@ impl ToCss for NonTSPseudoClass { match *self { $(NonTSPseudoClass::$name => concat!(":", $css),)* $(NonTSPseudoClass::$s_name(ref s) => { - return write!(dest, concat!(":", $s_css, "({})"), s) + write!(dest, concat!(":", $s_css, "("))?; + serialize_atom_identifier(s, dest)?; + return dest.write_char(')'); }, )* NonTSPseudoClass::MozLocaleDir(ref dir) => { dest.write_str(":-moz-locale-dir(")?; @@ -99,7 +102,7 @@ impl ToCss for NonTSPseudoClass { dest.write_str(", ")?; selector.to_css(dest)?; } - return dest.write_str(")") + return dest.write_char(')') } } }