diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-31 11:47:49 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-31 11:47:49 +0000 |
commit | ecb7182f93594109970db1811057c35ca71f73b2 (patch) | |
tree | f737466f823ac5aaa538107a615bb35248235d37 | |
parent | 66dfa32fe052cc2a7e8155954706381dd52c02e1 (diff) |
merge revision(s) 60021: [Backport #13926]
HTTPHeader#add_field should allow binary [Bug #13926]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@62133 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | lib/net/http/header.rb | 4 | ||||
-rw-r--r-- | test/net/http/test_httpheader.rb | 9 | ||||
-rw-r--r-- | version.h | 2 |
4 files changed, 13 insertions, 6 deletions
@@ -1,3 +1,7 @@ +Wed Jan 31 20:47:07 2018 NARUSE, Yui <naruse@ruby-lang.org> + + HTTPHeader#add_field should allow binary [Bug #13926] + Wed Jan 31 20:42:11 2018 Marcus Stollsteimer <sto.mar@web.de> ri.1: rewrite ri man page diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb index 7eee15e361..50580658d0 100644 --- a/lib/net/http/header.rb +++ b/lib/net/http/header.rb @@ -72,7 +72,7 @@ module Net::HTTPHeader @header[key.downcase] = ary else val = val.to_s - if /[\r\n]/ =~ val + if /[\r\n]/n =~ val.b raise ArgumentError, 'header field value cannnot include CR/LF' end @header[key.downcase] = [val] @@ -85,7 +85,7 @@ module Net::HTTPHeader val.each{|x| append_field_value(ary, x)} else val = val.to_s - if /[\r\n]/ =~ val + if /[\r\n]/n =~ val.b raise ArgumentError, 'header field value cannnot include CR/LF' end ary.push val diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb index 983ed01d1d..85fd3a3fec 100644 --- a/test/net/http/test_httpheader.rb +++ b/test/net/http/test_httpheader.rb @@ -45,6 +45,9 @@ class HTTPHeaderTest < Test::Unit::TestCase assert_equal 2, @c.length assert_equal ['aaa', 'bbb', '3'], @c.get_fields('aaa') + @c['aaa'] = "aaa\xff" + assert_equal 2, @c.length + assert_raise(ArgumentError){ @c['foo'] = "a\nb" } assert_raise(ArgumentError){ @c['foo'] = ["a\nb"] } end @@ -73,9 +76,9 @@ class HTTPHeaderTest < Test::Unit::TestCase assert_equal 'a, b, c, d, d', @c['My-Header'] assert_equal ['a', 'b', 'c', 'd, d'], @c.get_fields('My-Header') assert_raise(ArgumentError){ @c.add_field 'My-Header', "d\nd" } - @c.add_field 'My-Header', ['e', ['f', 7]] - assert_equal 'a, b, c, d, d, e, f, 7', @c['My-Header'] - assert_equal ['a', 'b', 'c', 'd, d', 'e', 'f', '7'], @c.get_fields('My-Header') + @c.add_field 'My-Header', ['e', ["\xff", 7]] + assert_equal "a, b, c, d, d, e, \xff, 7", @c['My-Header'] + assert_equal ['a', 'b', 'c', 'd, d', 'e', "\xff", '7'], @c.get_fields('My-Header') end def test_get_fields @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.3.7" #define RUBY_RELEASE_DATE "2018-01-31" -#define RUBY_PATCHLEVEL 394 +#define RUBY_PATCHLEVEL 395 #define RUBY_RELEASE_YEAR 2018 #define RUBY_RELEASE_MONTH 1 |