summaryrefslogtreecommitdiff
path: root/lib/net/http/header.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/net/http/header.rb')
-rw-r--r--lib/net/http/header.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 8f3206d363..25ff517ad5 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -18,7 +18,11 @@ module Net::HTTPHeader
if value.nil?
warn "net/http: warning: nil HTTP header: #{key}" if $VERBOSE
else
- @header[key.downcase] = [value.strip]
+ value = value.strip # raise error for invalid byte sequences
+ if value.count("\r\n") > 0
+ raise ArgumentError, 'header field value cannot include CR/LF'
+ end
+ @header[key.downcase] = [value]
end
end
end
@@ -75,8 +79,8 @@ module Net::HTTPHeader
append_field_value(ary, val)
@header[key.downcase] = ary
else
- val = val.to_s
- if /[\r\n]/n.match?(val.b)
+ val = val.to_s # for compatibility use to_s instead of to_str
+ if val.b.count("\r\n") > 0
raise ArgumentError, 'header field value cannnot include CR/LF'
end
@header[key.downcase] = [val]