Unquote and unescape Content-Type: charset [RFC7230]
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 83/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- ruby
- Domain
- networking
Research direction
Start in lib/net/http/header.rb at the parameter parsing code shown in the issue, then run the provided Net::HTTP reproduction against a response with a quoted charset. Verify that quoted and escaped Content-Type parameters produce a valid encoding name and that the request completes successfully; add regression coverage if the repository’s existing tests provide a suitable location.
Written by the indexing model from the issue text.
Description
uri = URI('http://127.0.0.1:8080')
http = Net::HTTP.new(uri.hostname, uri.port)
http.response_body_encoding = true
http.send_request('GET', uri.request_uri)
/opt/homebrew/lib/ruby/gems/4.0.0/gems/net-http-0.9.1/lib/net/http/response.rb:381:in 'String#force_encoding': unknown encoding name - "UTF-8" (ArgumentError)
@body.force_encoding(enc) if enc
from /opt/homebrew/lib/ruby/gems/4.0.0/gems/net-http-0.9.1/lib/net/http/response.rb:381:in 'Net::HTTPResponse#read_body'
$ curl -I http://127.0.0.1:8080/
Content-Type: text/html; charset="UTF-8"
Server: WEBrick/1.9.2 (Ruby/4.0.1/2026-01-13)
$ open https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6
[3.2.6](https://www.rfc-editor.org/rfc/rfc7230#section-3.2.6). Field Value Components
quoted-string = DQUOTE *( qdtext / quoted-pair ) DQUOTE
$ git diff
diff --git a/lib/net/http/header.rb b/lib/net/http/header.rb
index 797a3be..fe026ae 100644
--- a/lib/net/http/header.rb
+++ b/lib/net/http/header.rb
@@ -762,3 +762,3 @@ module Net::HTTPHeader
k, v = *param.split('=', 2)
- result[k.strip] = v.strip
+ result[k.strip] = v.strip.gsub(/\A"(.*?)(?<!\\)"\z/) { $1.gsub(/\\(.)/, '\1') }.strip
end
http.send_request('GET', uri.request_uri)
# #<Net::HTTPOK 200 OK readbody=true>
- Dominant language
- Ruby
- Stars
- 148
- Forks
- 95
- Avg merge
- 10h 54m
- Merged PRs (30d)
- 4
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ruby/net-http
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
bug documentation
Difficulty 4/5 3-5 days Newbie friendliness 45/100
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100