Skip to content

Commit 32d8a02

Browse files
committed
Use a regex that doesn't suffer from catastrophic backtracking
https://www.regular-expressions.info/catastrophic.html
1 parent 624bf9b commit 32d8a02

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lib/rack/contrib/jsonp.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ module Rack
77
class JSONP
88
include Rack::Utils
99

10-
VALID_JS_VAR = /[a-zA-Z_$][\w$]*/
11-
VALID_CALLBACK = /\A#{VALID_JS_VAR}(?:\.?#{VALID_JS_VAR})*\z/
10+
VALID_CALLBACK = /\A[a-zA-Z_$](?:\.?[\w$])*\z/
1211

1312
# These hold the Unicode characters \u2028 and \u2029.
1413
#

0 commit comments

Comments
 (0)