Skip to content

Commit

Permalink
fix double encoding of oauth_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mttkay committed Mar 21, 2010
1 parent 69fa5f6 commit 6e69a3e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public HttpRequest sign(HttpRequest request) throws OAuthMessageSignerException,
requestParameters = new HttpParameters();
try {
if (additionalParameters != null) {
requestParameters.putAll(additionalParameters, true);
requestParameters.putAll(additionalParameters, false);
}
collectHeaderParameters(request, requestParameters);
collectQueryParameters(request, requestParameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,16 @@ protected void retrieveToken(OAuthConsumer consumer, String endpointUrl,
for (String header : defaultHeaders.keySet()) {
request.setHeader(header, defaultHeaders.get(header));
}
if (this.listener != null) {
this.listener.prepareRequest(request);
}

if (additionalParameters != null) {
HttpParameters httpParams = new HttpParameters();
httpParams.putAll(additionalParameters, true);
consumer.setAdditionalParameters(httpParams);
}

if (this.listener != null) {
this.listener.prepareRequest(request);
}

consumer.sign(request);

if (this.listener != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public interface OAuthConsumer extends Serializable {
* oauth_callback or oauth_verifier) which will go directly into the signer,
* i.e. you don't have to put them into the request first. The consumer's
* {@link SigningStrategy} will then take care of writing them to the
* correct part of the request before it is sent.
* correct part of the request before it is sent. Note that these parameters
* are expected to already be percent encoded -- they will be simply merged
* as-is.
*
* @param additionalParameters
* the parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public void shouldHonorManuallySetSigningParameters() throws Exception {
consumer.setMessageSigner(signer);

HttpParameters params = new HttpParameters();
params.put("oauth_callback", "oob");
params.put("oauth_callback", "http://mycallback");
consumer.setAdditionalParameters(params);

consumer.sign(request);
Expand All @@ -135,7 +135,7 @@ public void shouldHonorManuallySetSigningParameters() throws Exception {
ArgumentMatcher<HttpParameters> hasParameters = new ArgumentMatcher<HttpParameters>() {
public boolean matches(Object argument) {
HttpParameters params = (HttpParameters) argument;
assertEquals("oob", params.getFirst("oauth_callback"));
assertEquals("http://mycallback", params.getFirst("oauth_callback"));
assertEquals("1", params.getFirst("a"));
return true;
}
Expand Down

0 comments on commit 6e69a3e

Please sign in to comment.