diff --git a/lib/net/http/response.rb b/lib/net/http/response.rb
index 0b5b326..68e0376 100644
--- a/lib/net/http/response.rb
+++ b/lib/net/http/response.rb
@@ -472,40 +472,42 @@ def check_bom(str)
def scanning_meta(str)
require 'strscan'
ss = StringScanner.new(str)
- if ss.scan_until(/]*/)
name.downcase!
- raise if name.empty?
+ throw :invalid_meta_tag if name.empty?
ss.skip(/[\t\n\f\r ]*/)
if ss.getch != '='
value = ''
@@ -528,18 +530,18 @@ def get_attribute(ss)
case ss.peek(1)
when '"'
ss.getch
- value = ss.scan(/[^"]+/)
+ value = ss.scan(/[^"]*/)
value.downcase!
ss.getch
when "'"
ss.getch
- value = ss.scan(/[^']+/)
+ value = ss.scan(/[^']*/)
value.downcase!
ss.getch
when '>'
value = ''
else
- value = ss.scan(/[^\t\n\f\r >]+/)
+ throw :invalid_meta_tag unless value = ss.scan(/[^\t\n\f\r >]+/)
value.downcase!
end
[name, value]
diff --git a/test/net/http/test_httpresponse.rb b/test/net/http/test_httpresponse.rb
index 7e7ae8a..b113fe0 100644
--- a/test/net/http/test_httpresponse.rb
+++ b/test/net/http/test_httpresponse.rb
@@ -313,6 +313,78 @@ def test_read_body_body_encoding_true_with_iso8859_1_meta_content_charset
assert_equal Encoding::ISO_8859_1, body.encoding
end
+ def test_read_body_body_encoding_with_empty_attribute
+ res_body = "hello\u1234