Merge pull request #162 from snshn/colons-in-css-class-names

Escape colons within CSS idents
This commit is contained in:
Sunshine 2020-04-10 21:20:37 -04:00 committed by GitHub
commit cc6dbddb49
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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!(