File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change 179179# - #each_value: Passes each string field value to the block.
180180#
181181module Net ::HTTPHeader
182+ MAX_KEY_LENGTH = 1024
183+ MAX_FIELD_LENGTH = 65536
182184
183185 def initialize_http_header ( initheader ) #:nodoc:
184186 @header = { }
@@ -189,6 +191,12 @@ def initialize_http_header(initheader) #:nodoc:
189191 warn "net/http: nil HTTP header: #{ key } " , uplevel : 3 if $VERBOSE
190192 else
191193 value = value . strip # raise error for invalid byte sequences
194+ if key . bytesize > MAX_KEY_LENGTH
195+ raise ArgumentError , "too long (#{ key . bytesize } bytes) header: #{ key [ 0 , 30 ] . inspect } ..."
196+ end
197+ if value . bytesize > MAX_FIELD_LENGTH
198+ raise ArgumentError , "header #{ key } has too long field vallue: #{ value . bytesize } "
199+ end
192200 if value . count ( "\r \n " ) > 0
193201 raise ArgumentError , "header #{ key } has field value #{ value . inspect } , this cannot include CR/LF"
194202 end
You can’t perform that action at this time.
0 commit comments