stylo: Fix a serialization bug for string pseudos.

The string is null-terminated, so we need to avoid passing that last null
character.
This commit is contained in:
Emilio Cobos Álvarez 2017-04-24 19:28:11 +02:00
parent ef3903163d
commit e136863939
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -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(")")
}, )*