handle url edge case involving ; and no space between before style

This commit is contained in:
ConnorSkees 2020-04-24 19:13:38 -04:00
parent a5cd335318
commit 0969df8fe5
3 changed files with 15 additions and 2 deletions

View File

@ -303,6 +303,7 @@ pub(crate) fn eat_call_args<I: Iterator<Item = Token>>(
devour_whitespace_or_comment(toks)?;
let mut name = String::new();
let mut val: Vec<Token> = Vec::new();
// todo: panics on a { color:rgb(; }
let mut span = toks.peek().unwrap().pos();
loop {
match toks.peek().unwrap().kind {

View File

@ -106,6 +106,7 @@ pub(crate) use crate::token::Token;
use crate::utils::{
devour_whitespace, eat_comment, eat_ident, eat_ident_no_interpolation, eat_variable_value,
parse_quoted_string, read_until_closing_curly_brace, read_until_newline, VariableDecl,
read_until_closing_paren
};
use crate::value::Value;
@ -713,6 +714,12 @@ pub(crate) fn eat_expr<I: Iterator<Item = Token>>(
values.push(toks.next().unwrap());
values.push(toks.next().unwrap());
}
// todo: this should only apply to special functions
// it is causing us to emit nothing on malformed input
'(' => {
values.push(toks.next().unwrap());
values.extend(read_until_closing_paren(toks));
}
_ => values.push(toks.next().unwrap()),
};
}

View File

@ -111,11 +111,16 @@ test!(
test!(url_dot_dot, "a {\n color: url(../foo/bar/..baz/);\n}\n");
test!(
silent_comment_in_interpolation,
"$roboto-font-path: \"../fonts/roboto\";\n\na {\n color: url(#{//}\n $roboto-font-path})\n}\n",
"$roboto-font-path: \"../fonts/roboto\";\n\na {\n color: url(#{//}\n $roboto-font-path});\n}\n",
"a {\n color: url(../fonts/roboto);\n}\n"
);
test!(
interpolation_in_nested_url,
"a {\n color: url(url(#{foo}))\n}\n",
"a {\n color: url(url(#{foo}));\n}\n",
"a {\n color: url(url(foo));\n}\n"
);
test!(
no_space_after_colon_and_contains_semicolon,
"a {\n color:url(;);\n}\n",
"a {\n color: url(;);\n}\n"
);