mirror of
https://github.com/samsonjs/simple_oauth.git
synced 2026-03-25 08:45:54 +00:00
Fix the reserved characters regex to be non-variant by KCODE
This commit is contained in:
parent
bfbe667da4
commit
a39ceda4ba
2 changed files with 14 additions and 1 deletions
|
|
@ -24,7 +24,7 @@ module SimpleOAuth
|
|||
end
|
||||
|
||||
def self.encode(value)
|
||||
URI.encode(value.to_s, /[^\w\-\.\~]/)
|
||||
URI.encode(value.to_s, /[^a-z0-9\-\.\_\~]/i)
|
||||
end
|
||||
|
||||
def self.decode(value)
|
||||
|
|
|
|||
|
|
@ -30,6 +30,19 @@ class SimpleOAuthTest < Test::Unit::TestCase
|
|||
['-', '.', '~'].each do |character|
|
||||
assert_equal character, SimpleOAuth::Header.encode(character)
|
||||
end
|
||||
|
||||
major, minor, patch = RUBY_VERSION.split('.')
|
||||
new_ruby = major.to_i >= 2 || major.to_i == 1 && minor.to_i >= 9
|
||||
old_kcode = $KCODE if !new_ruby
|
||||
begin
|
||||
%w(n N e E s S u U).each do |kcode|
|
||||
$KCODE = kcode if !new_ruby
|
||||
assert_equal '%E3%81%82', SimpleOAuth::Header.encode('あ'), "Failed to correctly escape Japanese under $KCODE = #{kcode}"
|
||||
assert_equal '%C3%A9', SimpleOAuth::Header.encode('é'), "Failed to correctly escape e+acute under $KCODE = #{kcode}"
|
||||
end
|
||||
ensure
|
||||
$KCODE = old_kcode if !new_ruby
|
||||
end
|
||||
end
|
||||
|
||||
def test_decode
|
||||
|
|
|
|||
Loading…
Reference in a new issue