[rubygems/rubygems] Add charset to Webauthn response content-type

https://github.com/rubygems/rubygems/commit/442a3e8f37
This commit is contained in:
Jenny Shen 2023-07-23 19:18:44 -04:00 committed by git
parent db80e947a3
commit 17b50cdb68
3 changed files with 6 additions and 6 deletions

View File

@ -81,7 +81,7 @@ module Gem::GemcutterUtilities
def add_body
return unless body
@http_response["content-type"] = "text/plain"
@http_response["content-type"] = "text/plain; charset=utf-8"
@http_response["content-length"] = body.bytesize
@http_response.instance_variable_set(:@body, body)
end

View File

@ -55,7 +55,7 @@ class WebauthnListenerTest < Gem::TestCase
response = Gem::MockBrowser.get URI("http://localhost:#{@port}?code=xyz")
assert response.is_a? Net::HTTPOK
assert_equal "text/plain", response["Content-Type"]
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
assert_equal "7", response["Content-Length"]
assert_equal Gem.host, response["access-control-allow-origin"]
assert_equal "POST", response["access-control-allow-methods"]
@ -96,7 +96,7 @@ class WebauthnListenerTest < Gem::TestCase
response = Gem::MockBrowser.get URI("http://localhost:#{@port}")
assert response.is_a? Net::HTTPBadRequest
assert_equal "text/plain", response["Content-Type"]
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
assert_equal "22", response["Content-Length"]
assert_equal "close", response["Connection"]
assert_equal "missing code parameter", response.body
@ -110,7 +110,7 @@ class WebauthnListenerTest < Gem::TestCase
response = Gem::MockBrowser.get URI("http://localhost:#{@port}?param=xyz")
assert response.is_a? Net::HTTPBadRequest
assert_equal "text/plain", response["Content-Type"]
assert_equal "text/plain; charset=utf-8", response["Content-Type"]
assert_equal "22", response["Content-Length"]
assert_equal "close", response["Connection"]
assert_equal "missing code parameter", response.body

View File

@ -18,7 +18,7 @@ class WebauthnListenerResponseTest < Gem::TestCase
access-control-allow-origin: rubygems.example\r
access-control-allow-methods: POST\r
access-control-allow-headers: Content-Type, Authorization, x-csrf-token\r
content-type: text/plain\r
content-type: text/plain; charset=utf-8\r
content-length: 7\r
\r
success
@ -82,7 +82,7 @@ class WebauthnListenerResponseTest < Gem::TestCase
access-control-allow-origin: rubygems.example\r
access-control-allow-methods: POST\r
access-control-allow-headers: Content-Type, Authorization, x-csrf-token\r
content-type: text/plain\r
content-type: text/plain; charset=utf-8\r
content-length: 22\r
\r
missing code parameter