Skip to content

Commit

Permalink
Fix regex warnings in const.rb & test_launcher.rb
Browse files Browse the repository at this point in the history
Fix Puma::Const::ILLEGAL_HEADER_KEY_REGEX overlap

Add backslash as illegal character for header field-name

See puma#2495 and puma#2439

Update test_launcher.rb, use parenthesis with regex parameters
  • Loading branch information
MSP-Greg committed Nov 28, 2020
1 parent 5a988f1 commit 6c9cde8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/puma/const.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ module Const

# Illegal character in the key or value of response header
DQUOTE = "\"".freeze
HTTP_HEADER_DELIMITER = Regexp.escape("(),/:;<=>?@[]{}").freeze
ILLEGAL_HEADER_KEY_REGEX = /(\u0000-\u0025|#{DQUOTE}|#{HTTP_HEADER_DELIMITER})/.freeze
ILLEGAL_HEADER_VALUE_REGEX = /[\000-\037]/.freeze
HTTP_HEADER_DELIMITER = Regexp.escape("(),/:;<=>?@[]{}\\").freeze
ILLEGAL_HEADER_KEY_REGEX = /[\x00-\x20#{DQUOTE}#{HTTP_HEADER_DELIMITER}]/.freeze
ILLEGAL_HEADER_VALUE_REGEX = /[\x00-\x25]/.freeze

# Banned keys of response header
BANNED_HEADER_KEY = /rack.|status/.freeze
Expand Down
2 changes: 1 addition & 1 deletion test/test_launcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def test_log_config_enabled
end

def test_log_config_disabled
refute_match /Configuration:/, launcher.events.stdout.string
refute_match(/Configuration:/, launcher.events.stdout.string)
end

private
Expand Down

0 comments on commit 6c9cde8

Please sign in to comment.