Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/net/http/header.rb
Original file line number Diff line number Diff line change
Expand Up @@ -773,8 +773,16 @@ def type_params
list = self['Content-Type'].to_s.split(';')
list.shift
list.each do |param|
k, v = *param.split('=', 2)
result[k.strip] = v.strip
k, v = param.split('=', 2)
k.strip!
v.strip!
v.gsub!(/\A"(.*?)(?<!\\)"\z/) do
v2 = $1
v2.gsub!(/\\(.)/, '\1')
v2
end
v.strip!
result[k] = v
end
result
end
Expand Down
2 changes: 2 additions & 0 deletions test/net/http/test_httpheader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ def test_type_params
assert_equal({'charset' => 'iso-2022-jp'}, @c.type_params)
@c.content_type = 'text'
assert_equal({}, @c.type_params)
@c['content-type'] = 'text/html; charset="UTF\-8"'
assert_equal({'charset' => 'UTF-8'}, @c.type_params)
end

def test_set_content_type
Expand Down
Loading