-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
RESTEasy ResponseBuilder.location Inadvertently Decodes Path Segments in Relative URI #33419
Comments
/cc @FroMage (resteasy-reactive), @Sgitario (resteasy-reactive), @stuartwdouglas (resteasy-reactive) |
@gilday I guess the assertion in your reproducer is wrong: .header("Location", matchesPattern("http://localhost:\\d+/greeting/en-us")); Instead, you would expect to be: .header("Location", endsWith("greeting/en%2Fus")); @geoand I've checked RESTEasy classic and it returns the raw params |
You can certainly try that change, but my guess is that the TCK will fail |
Yes, I had two test cases in there, and I deleted the wrong one 🤦🏻♂️ |
When providing a location, the URI was being decoded, so the value was being altered from what users set. Note that these changes are based on what Resteasy already does: https://github.com/resteasy/resteasy/blob/dadddfb699a875c44ba05c0abe176873acbd9aa2/resteasy-core/src/main/java/org/jboss/resteasy/specimpl/ResponseBuilderImpl.java#L187 Fix quarkusio#33419
#33448 should include these changes. |
When providing a location, the URI was being decoded, so the value was being altered from what users set. Note that these changes are based on what Resteasy already does: https://github.com/resteasy/resteasy/blob/dadddfb699a875c44ba05c0abe176873acbd9aa2/resteasy-core/src/main/java/org/jboss/resteasy/specimpl/ResponseBuilderImpl.java#L187 Fix quarkusio#33419 (cherry picked from commit ced8b0a)
When providing a location, the URI was being decoded, so the value was being altered from what users set. Note that these changes are based on what Resteasy already does: https://github.com/resteasy/resteasy/blob/dadddfb699a875c44ba05c0abe176873acbd9aa2/resteasy-core/src/main/java/org/jboss/resteasy/specimpl/ResponseBuilderImpl.java#L187 Fix quarkusio#33419 (cherry picked from commit ced8b0a)
When providing a location, the URI was being decoded, so the value was being altered from what users set. Note that these changes are based on what Resteasy already does: https://github.com/resteasy/resteasy/blob/dadddfb699a875c44ba05c0abe176873acbd9aa2/resteasy-core/src/main/java/org/jboss/resteasy/specimpl/ResponseBuilderImpl.java#L187 Fix quarkusio#33419 (cherry picked from commit ced8b0a)
When providing a location, the URI was being decoded, so the value was being altered from what users set. Note that these changes are based on what Resteasy already does: https://github.com/resteasy/resteasy/blob/dadddfb699a875c44ba05c0abe176873acbd9aa2/resteasy-core/src/main/java/org/jboss/resteasy/specimpl/ResponseBuilderImpl.java#L187 Fix quarkusio#33419 (cherry picked from commit ced8b0a)
Describe the bug
The
ResponseBuilder.location(URI)
method accepts relative URIs and will build an absolute URI relative to the base URI to put in theLocation
header. When the relative URI contains URL-encoded path segments,ResponseBuilder.location
erroneously decodes those segments when building the new absolute URI.For example, the given JAX-RS resource method should build an HTTP response with a
Location
header that has the URI path/items/foo%2Fbar
, but it instead returns/items/foo/bar
.Expected behavior
ResponseBuilder.location
creates an absolute URI without changing the semantics of the URI path.Actual behavior
ResponseBuilder.location
creates an absolute URI with a URI path that has different semantics.How to Reproduce?
quarkus-resteasy-reactive-uri-decode-issue.tar.gz
The attached reproducer includes a test that demonstrates the issue through a failure. The test fails with a message like
because the URI path should have been
/greeting/en%2Fus
Output of
uname -a
orver
Darwin pixee-mbp-gilday.localdomain 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
Output of
java -version
openjdk version "17.0.7" 2023-04-18 OpenJDK Runtime Environment Temurin-17.0.7+7 (build 17.0.7+7) OpenJDK 64-Bit Server VM Temurin-17.0.7+7 (build 17.0.7+7, mixed mode)
GraalVM version (if different from Java)
No response
Quarkus version or git rev
3.0.3.Final
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.8.8 (4c87b05d9aedce574290d1acc98575ed5eb6cd39) Maven home: /Users/jgilday/.m2/wrapper/dists/apache-maven-3.8.8-bin/67c30f74/apache-maven-3.8.8 Java version: 17.0.7, vendor: Eclipse Adoptium, runtime: /Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home Default locale: en_US, platform encoding: UTF-8 OS name: "mac os x", version: "13.3.1", arch: "aarch64", family: "mac"
Additional information
No response
The text was updated successfully, but these errors were encountered: