diff --git a/.gitignore b/.gitignore index 6aed95b2..ecd62df3 100644 --- a/.gitignore +++ b/.gitignore @@ -80,3 +80,6 @@ target/ # Generated by parse.py -p stats.prof + +# IDE +.idea diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py index dc801668..6315a1c5 100644 --- a/html5lib/filters/sanitizer.py +++ b/html5lib/filters/sanitizer.py @@ -855,7 +855,7 @@ def sanitize_css(self, style): 'padding']: for keyword in value.split(): if keyword not in self.allowed_css_keywords and \ - not re.match(r"^(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$", keyword): # noqa + not re.match(r"^(#[0-9a-fA-F]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|\d{0,2}\.?\d{0,2}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)$", keyword): # noqa break else: clean.append(prop + ': ' + value + ';') diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py index e19deea8..45046d57 100644 --- a/html5lib/tests/test_sanitizer.py +++ b/html5lib/tests/test_sanitizer.py @@ -113,3 +113,15 @@ def test_sanitizer(): yield (runSanitizerTest, "test_should_allow_uppercase_%s_uris" % protocol, "foo" % (protocol, rest_of_uri), """foo""" % (protocol, rest_of_uri)) + + +def test_lowercase_color_codes_in_style(): + sanitized = sanitize_html("

") + expected = '

' + assert expected == sanitized + + +def test_uppercase_color_codes_in_style(): + sanitized = sanitize_html("

") + expected = '

' + assert expected == sanitized