Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MCC-286290] Add # to signature escape #7

Merged
merged 5 commits into from
Mar 29, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cleaned up regex
Wesley Davis committed Mar 16, 2017

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit dcb78c1ca242fb725dae9100fb65c4fa9c1f78ff
2 changes: 1 addition & 1 deletion lib/mauth/client.rb
Original file line number Diff line number Diff line change
@@ -366,7 +366,7 @@ def signature_valid!(object)
# do a moderately complex Euresource-style reencoding of the path
object.attributes_for_signing[:request_url] = CGI.escape(original_request_uri.to_s)
# decode forward slash and octothorpes back into characters like Euresource does
object.attributes_for_signing[:request_url].gsub!(/\w+/, '%2F' => '/', '%23' => '#')
object.attributes_for_signing[:request_url].gsub!(/%2F|%23/, "%2F" => "/", "%23" => "#")
expected_euresource_style_reencoding = object.string_to_sign(time: object.x_mws_time, app_uuid: object.signature_app_uuid)

# reset the object original request_uri, just in case we need it again
2 changes: 1 addition & 1 deletion spec/mauth_client_spec.rb
Original file line number Diff line number Diff line change
@@ -236,7 +236,7 @@ def x_mws_authentication
it "considers a request to be authentic even if the request_url must be CGI::escape'ed (after being escaped in Euresource's own idiosyncratic way) before authenticity is achieved" do
['/v1/users/[email protected]', "! # $ & ' ( ) * + , / : ; = ? @ [ ]"].each do |path|
# imagine what are on the requester's side now...
signed_path = CGI.escape(path).gsub!(/\w+/, '%2F' => '/', '%23' => '#') # This is what Euresource does to the path on the requester's side before the signing of the outgoing request occurs.
signed_path = CGI.escape(path).gsub!(/%2F|%23/, "%2F" => "/", "%23" => "#") # This is what Euresource does to the path on the requester's side before the signing of the outgoing request occurs.
request = TestSignableRequest.new(:verb => 'GET', :request_url => signed_path)
signed_request = @signing_mc.signed(request)