Skip to content

Empty DOM attribute crashes tokenizer #311

Description

@forthrin
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

Activity

  1. jeremyevans commented on Jul 11, 2026

    @jeremyevans
    Contributor

    Thank you for the report. I submitted #314 to fix this issue.

  2. added a commit that references this issue on Jul 11, 2026
    2b9450f
  3. forthrin commented on Jul 11, 2026

    @forthrin
    Author

    You're welcome! Thanks for the quick fix. Will close when it hits the next official Homebrew release.

  4. added a commit that references this issue on Aug 27, 2026
    12ac182
  5. forthrin commented on Sep 15, 2026

    @forthrin
    Author

    Anything holding back merging these fixes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions