summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenny Shen <jenny.shen@shopify.com>2023-07-23 19:18:44 -0400
committergit <svn-admin@ruby-lang.org>2023-07-28 16:08:11 +0000
commit17b50cdb68ce016caee0d6fef8e8438a5bf5addb (patch)
tree82fe775024309a6cf2a431760594c261327bb943
parentdb80e947a382a6a9ef2295e81f5b97c6a8ecbce7 (diff)
[rubygems/rubygems] Add charset to Webauthn response content-type
https://github.com/rubygems/rubygems/commit/442a3e8f37
-rw-r--r--lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb2
-rw-r--r--test/rubygems/test_webauthn_listener.rb6
-rw-r--r--test/rubygems/test_webauthn_listener_response.rb4
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb b/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb
index c0e2778485..7709a8fef3 100644
--- a/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb
+++ b/lib/rubygems/gemcutter_utilities/webauthn_listener/response.rb
@@ -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
diff --git a/test/rubygems/test_webauthn_listener.rb b/test/rubygems/test_webauthn_listener.rb
index 45745eb935..5e91064b49 100644
--- a/test/rubygems/test_webauthn_listener.rb
+++ b/test/rubygems/test_webauthn_listener.rb
@@ -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
diff --git a/test/rubygems/test_webauthn_listener_response.rb b/test/rubygems/test_webauthn_listener_response.rb
index ce617ebada..377e5bfe5a 100644
--- a/test/rubygems/test_webauthn_listener_response.rb
+++ b/test/rubygems/test_webauthn_listener_response.rb
@@ -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