better handle strings passed to special css functions

This commit is contained in:
Connor Skees 2020-08-17 04:35:00 -04:00
parent d2a39e274d
commit 7acaa94870
3 changed files with 19 additions and 1 deletions

View File

@ -248,7 +248,7 @@ impl<'a> Parser<'a> {
return Ok(Spanned { return Ok(Spanned {
node: Value::String(s, QuoteKind::Quoted), node: Value::String(s, QuoteKind::Quoted),
span, span,
}) });
} }
'\'' if q == '\'' => { '\'' if q == '\'' => {
return Ok(Spanned { return Ok(Spanned {

View File

@ -47,6 +47,14 @@ impl<'a> Parser<'a> {
buf.push(')'); buf.push(')');
} }
} }
q @ '\'' | q @ '"' => {
buf.push(q);
match self.parse_quoted_string(q)?.node {
Value::String(ref s, ..) => buf.push_str(s),
_ => unreachable!(),
}
buf.push(q);
}
c => buf.push(c), c => buf.push(c),
} }
} }

View File

@ -49,6 +49,16 @@ test!(
"a {\n color: -webkit-calc(1 + 2);\n}\n", "a {\n color: -webkit-calc(1 + 2);\n}\n",
"a {\n color: -webkit-calc(1 + 2);\n}\n" "a {\n color: -webkit-calc(1 + 2);\n}\n"
); );
test!(
calc_quoted_string,
r#"a { color: calc("\ "); }"#,
"a {\n color: calc(\" \");\n}\n"
);
test!(
calc_quoted_string_single_quoted_paren,
"a {\n color: calc(\")\");\n}\n",
"a {\n color: calc(\")\");\n}\n"
);
test!( test!(
element_whitespace, element_whitespace,
"a {\n color: element( 1 );\n}\n", "a {\n color: element( 1 );\n}\n",