Skip to content

Commit

Permalink
Merge pull request #34 from axonivy-market/fix-path-enconding
Browse files Browse the repository at this point in the history
XIVY-15609 Improve path encoding for signing request
  • Loading branch information
alexsuter authored Dec 6, 2024
2 parents b86884e + 51c867c commit 0a48fde
Showing 1 changed file with 10 additions and 6 deletions.
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

0 comments on commit 0a48fde

Please sign in to comment.