Merge pull request #191 from snshn/trim-style

Trim CSS if it contains nothing but whitespaces
pull/192/head
Sunshine 4 years ago committed by GitHub
commit fb835fae28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -394,6 +394,11 @@ pub fn process_css<'a>(
}
}
// Ensure empty CSS is really empty
if result.len() > 0 && result.trim().len() == 0 {
result = result.trim().to_string()
}
Ok(result)
}

@ -143,7 +143,7 @@ mod passing {
std::str::from_utf8(&out.stdout).unwrap(),
"<html><head>\
<meta http-equiv=\"Content-Security-Policy\" content=\"font-src 'none';\"></meta>\
<style> </style>\
<style></style>\
</head><body>Hi</body></html>\n"
);

@ -22,6 +22,25 @@ mod passing {
);
}
#[test]
fn trim_if_empty() {
let cache = &mut HashMap::new();
let client = Client::new();
assert_eq!(
css::embed_css(
cache,
&client,
"https://doesntmatter.local/",
"\t \t ",
false,
false,
false,
),
""
);
}
#[test]
fn style_exclude_unquoted_images() {
let cache = &mut HashMap::new();

Loading…
Cancel
Save