Skip to content

Commit

Permalink
Fix the reserved characters regex to be non-variant by $KCODE
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Sanford authored and mojodna committed Apr 22, 2009
1 parent dd3bcd1 commit 470c08e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
1 change: 1 addition & 0 deletions History.txt
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


* Corrected OAuth XMPP namespace (Seth) * Corrected OAuth XMPP namespace (Seth)
* Improved error handling for invalid Authorization headers (Matt Sanford) * Improved error handling for invalid Authorization headers (Matt Sanford)
* Fixed signatures for non-ASCII under $KCODE other than 'u' (Matt Sanford)


== 0.3.2 2009-03-23 == 0.3.2 2009-03-23


Expand Down
2 changes: 1 addition & 1 deletion lib/oauth/oauth.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ module OAuth
PARAMETERS = %w(oauth_consumer_key oauth_token oauth_signature_method oauth_timestamp oauth_nonce oauth_version oauth_signature) PARAMETERS = %w(oauth_consumer_key oauth_token oauth_signature_method oauth_timestamp oauth_nonce oauth_version oauth_signature)


# reserved character regexp, per section 5.1 # reserved character regexp, per section 5.1
RESERVED_CHARACTERS = /[^\w\d\-\.\_\~]/ RESERVED_CHARACTERS = /[^a-zA-Z0-9\-\.\_\~]/
end end
30 changes: 19 additions & 11 deletions test/test_signature.rb
Original file line number Original file line Diff line number Diff line change
@@ -1,11 +1,19 @@
require File.dirname(__FILE__) + '/test_helper.rb' require File.dirname(__FILE__) + '/test_helper.rb'


class TestOauth < Test::Unit::TestCase class TestOauth < Test::Unit::TestCase


def setup def test_parameter_escaping_kcode_invariant
end old = $KCODE

begin
def test_truth %w(n N e E s S u U).each do |kcode|
assert true $KCODE = kcode
end assert_equal '%E3%81%82', OAuth::Helper.escape('あ'),
end "Failed to correctly escape Japanese under $KCODE = #{kcode}"
assert_equal '%C3%A9', OAuth::Helper.escape('é'),
"Failed to correctly escape e+acute under $KCODE = #{kcode}"
end
ensure
$KCODE = old
end
end
end

0 comments on commit 470c08e

Please sign in to comment.