From e1368639390e1cbf8b9aa4cf81cc167c8a640b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Mon, 24 Apr 2017 19:28:11 +0200 Subject: [PATCH] stylo: Fix a serialization bug for string pseudos. The string is null-terminated, so we need to avoid passing that last null character. --- components/style/gecko/selector_parser.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/style/gecko/selector_parser.rs b/components/style/gecko/selector_parser.rs index e87336669d5..95b7ab82ac5 100644 --- a/components/style/gecko/selector_parser.rs +++ b/components/style/gecko/selector_parser.rs @@ -235,8 +235,12 @@ impl ToCss for NonTSPseudoClass { $(NonTSPseudoClass::$s_name(ref s) => { write!(dest, ":{}(", $s_css)?; { + // FIXME(emilio): Avoid the extra allocation! let mut css = CssStringWriter::new(dest); - css.write_str(&String::from_utf16(&s).unwrap())?; + + // Discount the null char in the end from the + // string. + css.write_str(&String::from_utf16(&s[..s.len() - 1]).unwrap())?; } return dest.write_str(")") }, )*