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

[Bug] username and password parsing from URL does not handle percent encoding #186

Closed
Geal opened this issue Dec 7, 2023 · 1 comment
Closed
Assignees
Labels
bug Something isn't working

Comments

@Geal
Copy link

Geal commented Dec 7, 2023

the utils::parse_url_credentials method gets the username and password from the URL using its direct methods:

fred.rs/src/utils.rs

Lines 735 to 744 in aa7fc02

pub fn parse_url_credentials(url: &Url) -> (Option<String>, Option<String>) {
let username = if url.username().is_empty() {
None
} else {
Some(url.username().to_owned())
};
let password = url.password().map(|s| s.to_owned());
(username, password)
}

But those methods return the value as a percent encoded string: https://docs.rs/url/latest/url/struct.Url.html#method.username

Return the username for this URL (typically the empty string) as a percent-encoded ASCII string.

So if we are parsing the config from the URL redis://default:abc%2F123@localhost:6379, then the password that will be sent to Redis would be abc%2F123 instead of abc/123

@aembke
Copy link
Owner

aembke commented Dec 13, 2023

Thanks @Geal, this should be fixed in https://github.com/aembke/fred.rs/releases/tag/v7.1.0

@aembke aembke closed this as completed Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants