Skip to content

Commit

Permalink
fix: don't double encode query params in image proxy (closes #1252)
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jul 31, 2023
1 parent bab1b0d commit e7ae307
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import jakarta.servlet.http.HttpServletResponse;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.UnknownHostException;
import java.util.List;
Expand Down Expand Up @@ -44,7 +46,7 @@ public Object proxy(final HttpServletRequest request, final HttpServletResponse
ClientResponse clientResponse = null;
try {
clientResponse = this.webClient.get()
.uri(url)
.uri(new URL(url).toURI())
.headers((headers) -> this.passHeaders(headers, request))
.exchange().block(); // Block the request, we don't get the body at this point!
if (clientResponse == null) {
Expand Down Expand Up @@ -78,7 +80,7 @@ public Object proxy(final HttpServletRequest request, final HttpServletResponse
} else {
return ResponseEntity.badRequest().body("Bad content type");
}
} catch (final WebClientRequestException ex) {
} catch (final WebClientRequestException | MalformedURLException | URISyntaxException ex) {
return ResponseEntity.internalServerError().body("Encountered " + ex.getClass().getSimpleName() + " while trying to load " + url);
} finally {
if (clientResponse != null) {
Expand Down

0 comments on commit e7ae307

Please sign in to comment.