oauth1-signer-java icon indicating copy to clipboard operation
oauth1-signer-java copied to clipboard

[REQ] Code Improvement suggestion for unnecessary character replacment in the Util.percentEncode.

Open alanmehio opened this issue 1 year ago • 1 comments

Is your feature request related to a problem?

No

Describe the solution you'd like

The java class src/main/java/com/mastercard/developer/oauth/OAuth.java line 64 contains the below

// Signature
   String signature = signSignatureBaseString(sbs, signingKey, charset);
   oauthParams.put("oauth_signature", Util.percentEncode(signature, charset));

The method Util.percentEncode tries to replace the below characters "+", "*" and "%7E"
I am aware the java.net.URLEncode.encode does replace "+" with "%2B" and replace space character with "+" character The "signature" String is already base64 encoded which contains only from character 'A' to '0',.... '9'...'+','/', '='
see Base64 character table The '+' will be already encoded by the URLEncoder so the three characters replacement in the Util java class as below .replace("+", "%20") .replace("*", "%2A") .replace("%7E", "~");

Are not needed I think.

Describe alternatives you've considered

Please reconsider to remove the character replacement in the Util class com.mastercard.developer.oauth.Util line 32 to 34

Additional context

Do you recommend me to create a pull request (PR) to address the optimization issue mentioned above ?

alanmehio avatar Apr 09 '24 09:04 alanmehio

Hi @alanmehio

Thanks for reporting this issue. You are welcome to create a PR with your suggested optimization, our team can review this.

NehaSony avatar Apr 17 '24 13:04 NehaSony

Closing due to inactivity.

danny-gallagher avatar Aug 15 '24 08:08 danny-gallagher