Skip to content

Commit

Permalink
Merge pull request #165 from asok/correct-css-keywordish-regexp
Browse files Browse the repository at this point in the history
Correct the regexp for kewordish css property which hold hex values
  • Loading branch information
flavorjones committed Apr 23, 2019
2 parents cea7c93 + 6e623b8 commit 863806b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/loofah/html5/scrub.rb
Expand Up @@ -6,7 +6,7 @@ module HTML5 # :nodoc:
module Scrub

CONTROL_CHARACTERS = /[`\u0000-\u0020\u007f\u0080-\u0101]/
CSS_KEYWORDISH = /\A(#[0-9a-f]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|-?\d{0,3}\.?\d{0,10}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)\z/
CSS_KEYWORDISH = /\A(#[0-9a-fA-F]+|rgb\(\d+%?,\d*%?,?\d*%?\)?|-?\d{0,3}\.?\d{0,10}(cm|em|ex|in|mm|pc|pt|px|%|,|\))?)\z/
CRASS_SEMICOLON = {:node => :semicolon, :raw => ";"}

class << self
Expand Down
10 changes: 10 additions & 0 deletions test/html5/test_scrub.rb
@@ -0,0 +1,10 @@
require "helper"

class UnitHTML5Scrub < Loofah::TestCase
include Loofah

def test_scrub_css
assert_equal Loofah::HTML5::Scrub.scrub_css("background: #ABC012"), "background:#ABC012;"
assert_equal Loofah::HTML5::Scrub.scrub_css("background: #abc012"), "background:#abc012;"
end
end

0 comments on commit 863806b

Please sign in to comment.