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

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
@microkatz microkatz force-pushed the bugfix/rtsp_message_util_encoded_authority branch from 8ce1389 to 661f3de Compare September 12, 2024 04:57
@microkatz
Copy link
Contributor

@Lavamancer

I'm going to send this for internal review now. You may see some more commits being added as I make changes in response to review feedback. Please refrain from pushing any more substantive changes as it will complicate the internal review - thanks!

@copybara-service copybara-service bot merged commit 023fd32 into androidx:main Sep 13, 2024
1 check passed
@androidx androidx locked and limited conversation to collaborators Nov 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants