Skip to content
This repository

Fix requests containing !'()* in POST data #114

Merged
merged 1 commit into from over 1 year ago

4 participants

rolandboon Nayan Jain Nicolas Pelletier Ciaran Jessup
rolandboon

This pull request fixes the mismatch between the output of querystring.stringify() and this._encodeData(), as discussed in #113.

Credits for NicolasPelletier for identifying the cause of this issue: #113 (comment)

rolandboon Update lib/oauth.js
Fix the mismatch between the output of querystring.stringify() and this._encodeData(). 
240a992
Tylor Sherman tylor referenced this pull request in AvianFlu/ntwitter October 03, 2012
Open

v0.5.0 updateStatus error #74

Nayan Jain

LGTM

Nicolas Pelletier

Looks good to me too :)

Thanks for making this pull request rolandboon.

Ciaran Jessup
Owner

Sorry for the delay on this, any chance of running up a quick test case and I'll get it merged ASAP.

Nicolas Pelletier

Not at all. That is the beauty of open source. We could use this fix directly in the code on our server until you made the official version.

Thanks for a great and very useful module.

Cheers !

Ciaran Jessup ciaranj merged commit 45a983e into from November 25, 2012
Ciaran Jessup ciaranj closed this November 25, 2012
Ciaran Jessup
Owner

Merged, thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Sep 28, 2012
rolandboon Update lib/oauth.js
Fix the mismatch between the output of querystring.stringify() and this._encodeData(). 
240a992
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 7 additions and 1 deletion. Show diff stats Hide diff stats

  1. 8  lib/oauth.js
8  lib/oauth.js
@@ -327,7 +327,13 @@ exports.OAuth.prototype._performSecureRequest= function( oauth_token, oauth_toke
327 327
   }
328 328
 
329 329
   if( (method == "POST" || method == "PUT")  && ( post_body == null && extra_params != null) ) {
330  
-    post_body= querystring.stringify(extra_params);
  330
+    // Fix the mismatch between the output of querystring.stringify() and this._encodeData()
  331
+    post_body= querystring.stringify(extra_params)
  332
+                       .replace(/\!/g, "%21")
  333
+                       .replace(/\'/g, "%27")
  334
+                       .replace(/\(/g, "%28")
  335
+                       .replace(/\)/g, "%29")
  336
+                       .replace(/\*/g, "%2A");
331 337
   }
332 338
 
333 339
   headers["Content-length"]= post_body ? Buffer.byteLength(post_body) : 0;
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.