From 89456c8b40f7510941dea7ac1eb8441614d61b9a Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Mon, 26 Apr 2021 22:06:19 +0100 Subject: [PATCH] Handle UTF-8 correctly in monkey patched OAuth::Helper.escape Fixes #3185 --- config/initializers/oauth.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/config/initializers/oauth.rb b/config/initializers/oauth.rb index bad01dd3d..276fd350c 100644 --- a/config/initializers/oauth.rb +++ b/config/initializers/oauth.rb @@ -1,4 +1,5 @@ require "oauth/controllers/provider_controller" +require "oauth/helper" require "oauth/rack/oauth_filter" Rails.configuration.middleware.use OAuth::Rack::OAuthFilter @@ -7,8 +8,10 @@ module OAuth module Helper def escape(value) value.to_s.gsub(OAuth::RESERVED_CHARACTERS) do |c| - format("%%%02X", c.ord) - end + c.bytes.map do |b| + format("%%%02X", b) + end.join + end.force_encoding(Encoding::US_ASCII) end end -- 2.39.5