Skip to content

Commit 2164d4f

Browse files
committed
Avoid regex backtracking in Inflector.underscore
[CVE-2023-22796]
1 parent cd46b0e commit 2164d4f

File tree

1 file changed

+1
-1
lines changed
  • activesupport/lib/active_support/inflector

1 file changed

+1
-1
lines changed

activesupport/lib/active_support/inflector/methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def underscore(camel_cased_word)
9797
return camel_cased_word.to_s unless /[A-Z-]|::/.match?(camel_cased_word)
9898
word = camel_cased_word.to_s.gsub("::", "/")
9999
word.gsub!(inflections.acronyms_underscore_regex) { "#{$1 && '_' }#{$2.downcase}" }
100-
word.gsub!(/([A-Z]+)(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" }
100+
word.gsub!(/([A-Z])(?=[A-Z][a-z])|([a-z\d])(?=[A-Z])/) { ($1 || $2) << "_" }
101101
word.tr!("-", "_")
102102
word.downcase!
103103
word

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy