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

XIVY-15609 Improve path encoding for signing request #34

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
import static com.axonivy.connector.aws.authentication.Constants.SIGNED_HEADERS;
import static com.axonivy.connector.aws.authentication.Constants.X_AMZ_DATE;

import java.net.URI;
import java.net.URISyntaxException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;

import javax.ws.rs.client.ClientRequestContext;

Expand Down Expand Up @@ -41,13 +42,16 @@ private void appendPath() {
if (path == null || path.isEmpty()) {
path = "/";
}

try {
var encodedPath = new URI(null, null, path, null).toASCIIString();
var encodedPath = URLEncoder.encode(path, StandardCharsets.UTF_8.toString())
.replace("%2F", "/")
.replace("%7E", "~")
.replace("*", "%2A")
.replace("+", "%20");
builder.append(encodedPath);
builder.append('\n');
} catch (URISyntaxException ex) {
throw new RuntimeException(ex);
} catch (UnsupportedEncodingException ex) {
throw new RuntimeException("Unable to encode path " + path, ex);
}
}

Expand Down
Loading