Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
alanmehio opened this issue Apr 9, 2024 · 1 comment

Comments

@alanmehio
Copy link

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 there character 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 ?

@NehaSony
Copy link
Contributor

Hi @alanmehio

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants