Skip to content

Commit 4193120

Browse files
committed
Fix web-tier percent-encoding in OAuth connector. Brackets and other invalid characters are now encoded correctly.
git-svn-id: https://share-extras.googlecode.com/svn/trunk/Share OAuth@655 a3f5c567-fd0f-3a89-9b71-a290c5a5f590
1 parent 619a338 commit 4193120

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

source/java/org/sharextras/webscripts/connector/HttpOAuthConnector.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ private void applyAuthParams(Map<String, String> authParams)
247247
}
248248
}
249249

250+
/**
251+
* Percent-encode a parameter for construction of the base string and the Authorization header,
252+
* as specified in http://tools.ietf.org/html/rfc5849#section-3.6
253+
*
254+
* @param p Unencoded string
255+
* @return Encoded text
256+
*/
250257
private String encodeParameter(String p)
251258
{
252259
String encoded = URLEncoder.encodeUriComponent(p);
@@ -261,7 +268,8 @@ private String encodeParameter(String p)
261268
lastEnd = m.end();
262269
}
263270
sb.append(encoded.substring(lastEnd));
264-
return sb.toString();
271+
return sb.toString().replaceAll("!", "%21").replaceAll("\\(", "%28").replaceAll("\\)", "%29")
272+
.replaceAll("\\*", "%2A");
265273
}
266274

267275
@SuppressWarnings("unchecked")

0 commit comments

Comments
 (0)