Skip to content

Commit

Permalink
Fix CVE-2023-31606 (ReDOS possible in the sanitize_html function) (#75)
Browse files Browse the repository at this point in the history
* make regex faster with Atomic Grouping
* simplify fix
  • Loading branch information
korny committed Nov 2, 2023
1 parent dd7ee6c commit 8b13276
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/redcloth/formatters/html.rb
Expand Up @@ -324,7 +324,7 @@ def before_transform(text)
# Clean unauthorized tags.
def clean_html( text, allowed_tags = BASIC_TAGS )
text.gsub!( /<!\[CDATA\[/, '' )
text.gsub!( /<(\/*)([A-Za-z]\w*)([^>]*?)(\s?\/?)>/ ) do |m|
text.gsub!( /<(\/*)([A-Za-z]\w*+)([^>]*?)(\s?\/?)>/ ) do |m|
raw = $~
tag = raw[2].downcase
if allowed_tags.has_key? tag
Expand Down

0 comments on commit 8b13276

Please sign in to comment.