Skip to content

Commit 0b960f2

Browse files
committed
Fix OAuth HTTP POSTs
git-svn-id: https://share-extras.googlecode.com/svn/trunk/Share OAuth@637 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent ed8d2fb commit 0b960f2

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

source/web/extras/modules/oauth.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,10 @@ if (typeof Extras == "undefined" || !Extras)
472472

473473
obj.method = obj.method || Alfresco.util.Ajax.GET;
474474

475-
var objToParamString = function(o)
475+
var objToParamString = function(o, spaceChar)
476476
{
477477
var params = "", first = true, attr;
478+
spaceChar = spaceChar;
478479
for (attr in o)
479480
{
480481
if (o.hasOwnProperty(attr))
@@ -487,7 +488,10 @@ if (typeof Extras == "undefined" || !Extras)
487488
{
488489
params += "&";
489490
}
490-
params += encodeURIComponent(attr) + "=" + encodeURIComponent(o[attr]);
491+
params += encodeURIComponent(attr) + "=" +
492+
(YAHOO.lang.isUndefined(spaceChar) ? encodeURIComponent(o[attr]) : encodeURIComponent("" + o[attr]).
493+
replace("%20", spaceChar, "g").replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').
494+
replace(/\)/g, '%29').replace(/\*/g, '%2A'));
491495
}
492496
}
493497
return params;
@@ -504,11 +508,11 @@ if (typeof Extras == "undefined" || !Extras)
504508
var reqType = obj.requestContentType || Alfresco.util.Ajax.FORM;
505509
if (!YAHOO.lang.isValue(obj.dataStr))
506510
{
507-
if ((new RegExp("^\s*" + Alfresco.util.Ajax.FORM)).test(contentType))
511+
if ((new RegExp("^\s*" + Alfresco.util.Ajax.FORM)).test(reqType))
508512
{
509-
obj.dataStr = objToParamString(obj.dataObj);
513+
obj.dataStr = objToParamString(obj.dataObj, "+");
510514
}
511-
else if ((new RegExp("^\s*" + Alfresco.util.Ajax.JSON)).test(contentType))
515+
else if ((new RegExp("^\s*" + Alfresco.util.Ajax.JSON)).test(reqType))
512516
{
513517
obj.dataStr = YAHOO.lang.JSON.stringify(c.dataObj || {});
514518
}

0 commit comments

Comments
 (0)