From 6c9cde89ad4243802e5110c1bd4a256b243b657b Mon Sep 17 00:00:00 2001 From: MSP-Greg Date: Fri, 27 Nov 2020 11:48:26 -0600 Subject: [PATCH] Fix regex warnings in const.rb & test_launcher.rb Fix Puma::Const::ILLEGAL_HEADER_KEY_REGEX overlap Add backslash as illegal character for header field-name See https://github.com/puma/puma/pull/2495 and https://github.com/puma/puma/pull/2439 Update test_launcher.rb, use parenthesis with regex parameters --- lib/puma/const.rb | 6 +++--- test/test_launcher.rb | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/puma/const.rb b/lib/puma/const.rb index 12a804f630..d6ea42bf8b 100644 --- a/lib/puma/const.rb +++ b/lib/puma/const.rb @@ -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 diff --git a/test/test_launcher.rb b/test/test_launcher.rb index d765b8dce1..ac790dce6b 100644 --- a/test/test_launcher.rb +++ b/test/test_launcher.rb @@ -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