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

Fixed removal of user info for URLs that contain encoded @ characters #1138

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lavamancer
Copy link

This bug occurs when using email addresses encoded as the user (i.e: rtsp://user%40name:pass@foo.bar/foo.mkv)

The solution is simply to use the getEncodedAuthority method instead of getAuthority. This resolves the issue because getAuthority decodes the encoded "@" symbols before splitting, resulting in a malformed URL.

Malformed URL example: rtsp://name:pass/foo.mkv

After the fix, it properly returns: rtsp://foo.bar/foo.mkv

@icbaker
Copy link
Collaborator

icbaker commented Feb 28, 2024

Instead of manually splitting the encoded authority on @ in order to remove the user-info and leave just the host and port, I wonder if it would instead be better to manually concatenate uri.getHost() and uri.getPort(). Then we let the Uri class deal with the splitting and encoding issues. Would that still allow your test case to pass?

@Lavamancer
Copy link
Author

The removeUserInfo method is used with the confidence that it will only remove that part since some URLs not only contain host and port but also path, query parameters, etc. The current issue of certain %40 being converted to @ has been resolved, allowing emails to be used as usernames in the user information.

@microkatz microkatz self-assigned this Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants