Skip to content

Commit

Permalink
Fix bugs and improve (#152)
Browse files Browse the repository at this point in the history
* Remove unused @form_data

* Change addr and peeraddr to non-nil

* Fix typo of constant name

* Improve split arguments
  • Loading branch information
znz authored Nov 5, 2024
1 parent ef2c69d commit cb93ef8
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 14 deletions.
8 changes: 4 additions & 4 deletions lib/webrick/httpauth/authenticator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/webrick/httpauth/htgroup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/httpauth/htpasswd.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions lib/webrick/httprequest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -173,7 +172,8 @@ def initialize(config)
@accept_language = []
@body = +""

@addr = @peeraddr = nil
@addr = []
@peeraddr = []
@attributes = {}
@user = nil
@keep_alive = false
Expand Down
2 changes: 1 addition & 1 deletion sig/httpauth/authenticator.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ module WEBrick

ResponseField: String

InfoField: String
ResponseInfoField: String

AuthException: singleton(HTTPStatus::ClientError)
end
Expand Down
6 changes: 2 additions & 4 deletions sig/httprequest.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ module WEBrick

@query: Hash[String, HTTPUtils::FormData]?

@form_data: nil

@body: String

@remaining_size: Integer?
Expand Down Expand Up @@ -72,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]

Expand Down

0 comments on commit cb93ef8

Please sign in to comment.