]> git.openstreetmap.org Git - rails.git/blob - config/initializers/oauth.rb
Merge remote-tracking branch 'upstream/pull/5401'
[rails.git] / config / initializers / oauth.rb
1 require "oauth/helper"
2
3 module OAuth
4   module Helper
5     def escape(value)
6       value.to_s.gsub(OAuth::RESERVED_CHARACTERS) do |c|
7         c.bytes.map do |b|
8           format("%%%02X", b)
9         end.join
10       end.force_encoding(Encoding::US_ASCII)
11     end
12
13     def unescape(value)
14       value.to_s.gsub(/%\h{2}/) do |c|
15         c[1..].to_i(16).chr
16       end.force_encoding(Encoding::UTF_8)
17     end
18   end
19 end