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

Double URL encoding on redirect in 1.15.4 #1928

Closed
rickosborne opened this issue Mar 29, 2023 · 1 comment
Closed

Double URL encoding on redirect in 1.15.4 #1928

rickosborne opened this issue Mar 29, 2023 · 1 comment
Labels
duplicate This is a duplicate issue or root-cause of another issue
Milestone

Comments

@rickosborne
Copy link

It looks like changes to encodeUrl in 1.15.4 are causing URL double-encoding when redirected.

For example, the following exchange:

>>> GET /apostrophe-'
<<< 302 Moved
    Location: /apostrophe-%27

In 1.15.3, this works, and the new path is followed correctly. In 1.15.4, the redirect URL ends up being double-encoded to /apostrophe-%2527 instead. Which then leads to errors like 404s.

It seems to be this change:

jsoup-1.15.3...jsoup-1.15.4#diff-50cf357d24b529d8ec8ffd200e666d29cb8286c71733da1a27c9b32d1204d676

While tracking this down, I also noticed that the redirect handling code in HttpConnection$Response#execute(HttpConnection.Request, Response) also makes a call to encodeUrl:

String location = res.header(LOCATION);
// ...
URL redir = StringUtil.resolve(req.url(), location);
req.url(encodeUrl(redir));

This implies that any redirect which sends an already-encoded URL will get double-encoded.

@jhy
Copy link
Owner

jhy commented Mar 29, 2023

Thanks for the report. This is fixed in the upcoming 1.16.1 release with #1914 and #1902.

You could use a snapshot version in the meantime - mvn install after checking out the tip.

@jhy jhy closed this as completed Mar 29, 2023
@jhy jhy added the duplicate This is a duplicate issue or root-cause of another issue label Mar 29, 2023
@jhy jhy added this to the 1.16.1 milestone Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This is a duplicate issue or root-cause of another issue
Projects
None yet
Development

No branches or pull requests

2 participants