ruby-changes:49258
From: nagachika <ko1@a...>
Date: Thu, 21 Dec 2017 00:59:19 +0900 (JST)
Subject: [ruby-changes:49258] nagachika:r61373 (ruby_2_4): merge revision(s) 60021: [Backport #13926]
nagachika 2017-12-21 00:59:14 +0900 (Thu, 21 Dec 2017) New Revision: 61373 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=61373 Log: merge revision(s) 60021: [Backport #13926] HTTPHeader#add_field should allow binary [Bug #13926] Modified directories: branches/ruby_2_4/ Modified files: branches/ruby_2_4/lib/net/http/header.rb branches/ruby_2_4/test/net/http/test_httpheader.rb branches/ruby_2_4/version.h Index: ruby_2_4/test/net/http/test_httpheader.rb =================================================================== --- ruby_2_4/test/net/http/test_httpheader.rb (revision 61372) +++ ruby_2_4/test/net/http/test_httpheader.rb (revision 61373) @@ -45,6 +45,9 @@ class HTTPHeaderTest < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/net/http/test_httpheader.rb#L45 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::TestC https://github.com/ruby/ruby/blob/trunk/ruby_2_4/test/net/http/test_httpheader.rb#L76 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 Index: ruby_2_4/lib/net/http/header.rb =================================================================== --- ruby_2_4/lib/net/http/header.rb (revision 61372) +++ ruby_2_4/lib/net/http/header.rb (revision 61373) @@ -76,7 +76,7 @@ module Net::HTTPHeader https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/net/http/header.rb#L76 @header[key.downcase] = ary else val = val.to_s - if /[\r\n]/.match?(val) + if /[\r\n]/n.match?(val.b) raise ArgumentError, 'header field value cannnot include CR/LF' end @header[key.downcase] = [val] @@ -89,7 +89,7 @@ module Net::HTTPHeader https://github.com/ruby/ruby/blob/trunk/ruby_2_4/lib/net/http/header.rb#L89 val.each{|x| append_field_value(ary, x)} else val = val.to_s - if /[\r\n]/.match?(val) + if /[\r\n]/n.match?(val.b) raise ArgumentError, 'header field value cannnot include CR/LF' end ary.push val Index: ruby_2_4/version.h =================================================================== --- ruby_2_4/version.h (revision 61372) +++ ruby_2_4/version.h (revision 61373) @@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_4/version.h#L1 #define RUBY_VERSION "2.4.4" #define RUBY_RELEASE_DATE "2017-12-21" -#define RUBY_PATCHLEVEL 218 +#define RUBY_PATCHLEVEL 219 #define RUBY_RELEASE_YEAR 2017 #define RUBY_RELEASE_MONTH 12 Index: ruby_2_4 =================================================================== --- ruby_2_4 (revision 61372) +++ ruby_2_4 (revision 61373) Property changes on: ruby_2_4 ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /trunk:r60021 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/