summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 15:59:14 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-12-20 15:59:14 +0000
commitd2b5c16e1955b0f7887b15a505f5848669ae2935 (patch)
treeeef4704e51647ede9e76bfb9b5fb376bf2804012
parent888f1f24e90dc3bd2c196e39dc8469ec703b0572 (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_4@61373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--lib/net/http/header.rb4
-rw-r--r--test/net/http/test_httpheader.rb9
-rw-r--r--version.h2
3 files changed, 9 insertions, 6 deletions
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 4777ebf82a..8f3206d363 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -76,7 +76,7 @@ module Net::HTTPHeader
@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
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
diff --git a/test/net/http/test_httpheader.rb b/test/net/http/test_httpheader.rb
index 0a2c57dcb8..c9b8b3c406 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
diff --git a/version.h b/version.h
index 03d198a3df..337ab56512 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#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