From 0d44a78597ea7ccaadaf12290f5fed60e4c199f3 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 1 Nov 2024 08:36:40 +0900 Subject: [PATCH 1/4] Remove unused @form_data --- lib/webrick/httprequest.rb | 1 - sig/httprequest.rbs | 2 -- 2 files changed, 3 deletions(-) diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb index 1fa5dbb..2f380b4 100644 --- a/lib/webrick/httprequest.rb +++ b/lib/webrick/httprequest.rb @@ -162,7 +162,6 @@ def initialize(config) @script_name = @path_info = nil @query_string = nil @query = nil - @form_data = nil @raw_header = Array.new @header = nil diff --git a/sig/httprequest.rbs b/sig/httprequest.rbs index 15a1f4c..1f8c65f 100644 --- a/sig/httprequest.rbs +++ b/sig/httprequest.rbs @@ -8,8 +8,6 @@ module WEBrick @query: Hash[String, HTTPUtils::FormData]? - @form_data: nil - @body: String @remaining_size: Integer? From c52279b70bb56e7c530fa36318890a796573abd5 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 1 Nov 2024 08:44:51 +0900 Subject: [PATCH 2/4] Change addr and peeraddr to non-nil --- lib/webrick/httprequest.rb | 3 ++- sig/httprequest.rbs | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/webrick/httprequest.rb b/lib/webrick/httprequest.rb index 2f380b4..2b50037 100644 --- a/lib/webrick/httprequest.rb +++ b/lib/webrick/httprequest.rb @@ -172,7 +172,8 @@ def initialize(config) @accept_language = [] @body = +"" - @addr = @peeraddr = nil + @addr = [] + @peeraddr = [] @attributes = {} @user = nil @keep_alive = false diff --git a/sig/httprequest.rbs b/sig/httprequest.rbs index 1f8c65f..82c229e 100644 --- a/sig/httprequest.rbs +++ b/sig/httprequest.rbs @@ -70,9 +70,9 @@ module WEBrick attr_accessor user: String? - attr_reader addr: ([String, Integer, String, String] | [])? + attr_reader addr: ([String, Integer, String, String] | []) - attr_reader peeraddr: ([String, Integer, String, String] | [])? + attr_reader peeraddr: ([String, Integer, String, String] | []) attr_reader attributes: Hash[untyped, untyped] From ce51f05a95ac24cca59848a3a5bb260073adbd87 Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 1 Nov 2024 08:47:53 +0900 Subject: [PATCH 3/4] Fix typo of constant name --- lib/webrick/httpauth/authenticator.rb | 8 ++++---- sig/httpauth/authenticator.rbs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/webrick/httpauth/authenticator.rb b/lib/webrick/httpauth/authenticator.rb index a6ee28d..13b1c7e 100644 --- a/lib/webrick/httpauth/authenticator.rb +++ b/lib/webrick/httpauth/authenticator.rb @@ -108,10 +108,10 @@ def info(fmt, *args) # authentication schemes for proxies. module ProxyAuthenticator - RequestField = "Proxy-Authorization" # :nodoc: - ResponseField = "Proxy-Authenticate" # :nodoc: - InfoField = "Proxy-Authentication-Info" # :nodoc: - AuthException = HTTPStatus::ProxyAuthenticationRequired # :nodoc: + RequestField = "Proxy-Authorization" # :nodoc: + ResponseField = "Proxy-Authenticate" # :nodoc: + ResponseInfoField = "Proxy-Authentication-Info" # :nodoc: + AuthException = HTTPStatus::ProxyAuthenticationRequired # :nodoc: end end end diff --git a/sig/httpauth/authenticator.rbs b/sig/httpauth/authenticator.rbs index 394899d..fe94762 100644 --- a/sig/httpauth/authenticator.rbs +++ b/sig/httpauth/authenticator.rbs @@ -47,7 +47,7 @@ module WEBrick ResponseField: String - InfoField: String + ResponseInfoField: String AuthException: singleton(HTTPStatus::ClientError) end From c747d0ffcce7eb086e8b55f1a4cd5a29713fc49f Mon Sep 17 00:00:00 2001 From: Kazuhiro NISHIYAMA Date: Fri, 1 Nov 2024 08:50:30 +0900 Subject: [PATCH 4/4] Improve split arguments --- lib/webrick/httpauth/htgroup.rb | 2 +- lib/webrick/httpauth/htpasswd.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/webrick/httpauth/htgroup.rb b/lib/webrick/httpauth/htgroup.rb index 108c9d0..df19b85 100644 --- a/lib/webrick/httpauth/htgroup.rb +++ b/lib/webrick/httpauth/htgroup.rb @@ -49,7 +49,7 @@ def reload File.open(@path){|io| while line = io.gets line.chomp! - group, members = line.split(/:\s*/) + group, members = line.split(/:\s*/, 2) @group[group] = members.split(/\s+/) end } diff --git a/lib/webrick/httpauth/htpasswd.rb b/lib/webrick/httpauth/htpasswd.rb index 9a48e57..db70125 100644 --- a/lib/webrick/httpauth/htpasswd.rb +++ b/lib/webrick/httpauth/htpasswd.rb @@ -77,12 +77,12 @@ def reload if @password_hash == :bcrypt raise StandardError, ".htpasswd file contains crypt password, only bcrypt passwords supported" end - user, pass = line.split(":") + user, pass = line.split(":", 2) when %r!\A[^:]+:\$2[aby]\$\d{2}\$.{53}\z! if @password_hash == :crypt raise StandardError, ".htpasswd file contains bcrypt password, only crypt passwords supported" end - user, pass = line.split(":") + user, pass = line.split(":", 2) when /:\$/, /:{SHA}/ raise NotImplementedError, 'MD5, SHA1 .htpasswd file not supported'