From: Tom Hughes Date: Mon, 26 Apr 2021 21:06:19 +0000 (+0100) Subject: Handle UTF-8 correctly in monkey patched OAuth::Helper.escape X-Git-Tag: live~2118 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/89456c8b40f7510941dea7ac1eb8441614d61b9a?ds=inline Handle UTF-8 correctly in monkey patched OAuth::Helper.escape Fixes #3185 --- 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