escape colons within CSS idents

This commit is contained in:
Sunshine 2020-04-10 20:59:27 -04:00
parent ab601c3830
commit 9d3df2cdc6
No known key found for this signature in database
GPG key ID: B80CA68703CD8AB1
2 changed files with 25 additions and 2 deletions

View file

@ -122,7 +122,7 @@ pub fn process_css<'a>(
}
Token::Ident(ref value) => {
curr_prop = str!(value);
result.push_str(value);
result.push_str(&value.replace(":", "\\:"));
}
Token::AtKeyword(ref value) => {
curr_rule = str!(value);

View file

@ -209,7 +209,30 @@ div {\n \
transform: translate(50%, 50%) rotate(45deg);\n\
transform: translate(+50%, +50%) rotate(+45deg);\n\
}\n\
\n\
";
assert_eq!(
css::embed_css(
cache,
&client,
"https://doesntmatter.local/",
&CSS,
false,
true,
),
CSS
);
}
#[test]
fn passing_colons_in_class_names() {
let cache = &mut HashMap::new();
let client = Client::new();
const CSS: &str = "\
.is\\:good:hover {\n \
color: green\n\
}\n\
";
assert_eq!(