Empty DOM attribute crashes tokenizer
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- ruby
- Domain
- networking
Research direction
Review lib/net/http/response.rb at get_attribute and reproduce the failure with the provided request containing an empty attribute. Run rake test and confirm that parsing this response no longer raises, adding regression coverage if the existing test structure supports it.
Written by the indexing model from the issue text.
Description
require 'uri'
require 'net/http'
uri = URI('https://restaurangang.se/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.response_body_encoding = true
http.send_request('GET', uri.path)
net-http-0.9.1/lib/net/http/response.rb:in 'Net::HTTPResponse#get_attribute': undefined method 'downcase!' for nil
Breakdown:
<!DOCTYPE html>
<title>Validating Document</title>
<meta charset="utf-8" data-next-head="">
@jeremyevans wrote on 2022-04-11 08:17:19 -0700 :
$ git blame -L528,538 response.rb
case ss.peek(1)
when '"'
ss.getch
value = ss.scan(/[^"]+/)
value.downcase!
ss.getch
Works and passes rake test, but leaving to a seasoned dev what to ultimately commit.
diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 0b5b326..1fda33a 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -530,4 +530,3 @@ class Net::HTTPResponse
ss.getch
- value = ss.scan(/[^"]+/)
- value.downcase!
+ value = (ss.scan(/[^"]+/) || '').downcase
ss.getch
@@ -535,4 +534,3 @@ class Net::HTTPResponse
ss.getch
- value = ss.scan(/[^']+/)
- value.downcase!
+ value = (ss.scan(/[^']+/) || '').downcase
ss.getch
@@ -541,4 +539,3 @@ class Net::HTTPResponse
else
- value = ss.scan(/[^\t\n\f\r >]+/)
- value.downcase!
+ value = ss.scan(/[^\t\n\f\r >]+/).downcase
end
System Version: macOS 26.5.1 (25F80)
Model Identifier: MacBookAir10,1
ruby 4.0.5 (2026-05-20 revision 64336ffd0e) +PRISM [arm64-darwin25]
rubocop 2026-07-10 5e56132d8
- Dominant language
- Ruby
- Stars
- 148
- Forks
- 95
- Avg merge
- 10h 54m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/net-http
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
bug documentation
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100