Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix parsing and serialization of font-family #15183

Merged
merged 5 commits into from Jan 26, 2017

Properly escape font-family names in CSS serialization.

Fix #15059.
  • Loading branch information
SimonSapin committed Jan 24, 2017
commit bf1683659836aa7719615fc12789a7c08ce72a3e
@@ -19,7 +19,8 @@
impl NoViewportPercentage for SpecifiedValue {}

pub mod computed_value {
use std::fmt;
use cssparser::CssStringWriter;
use std::fmt::{self, Write};
use Atom;
use style_traits::ToCss;
pub use self::FontFamily as SingleComputedValue;
@@ -72,7 +73,16 @@

impl ToCss for FontFamily {
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.atom().with_str(|s| dest.write_str(s))
match *self {
FontFamily::FamilyName(ref name) => {
dest.write_char('"')?;
write!(CssStringWriter::new(dest), "{}", name)?;
dest.write_char('"')
}

// All generic values accepted by the parser are known to not require escaping.
FontFamily::Generic(ref name) => write!(dest, "{}", name),
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.