-
Notifications
You must be signed in to change notification settings - Fork 90
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
Support %-encoded characters in DID URL #1496
base: main
Are you sure you want to change the base?
Conversation
identity_did/src/did_url.rs
Outdated
pub(crate) fn is_valid_percent_encoded_char(s: &str) -> bool { | ||
let mut chars = s.chars(); | ||
let Some('%') = chars.next() else { return false }; | ||
chars.take(2).all(|c| c.is_ascii_hexdigit() && !c.is_ascii_lowercase()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, we should check the length of chars.take(2)
, as this would return an iterator with a length of 0 or 1, making wrongly percent encoded elements at the end of an input valid, e.g. relative_url.set_path(Some("/p%A"))
or relative_url.set_path(Some("/p%"))
.
Creates an iterator that yields the first n elements, or fewer if the underlying iterator ends sooner.
(from docs)
Co-authored-by: wulfraem <[email protected]>
Description of change
Allow the use of %-encoded characters in DID URLs.
Links to any relevant issues
Closes #1492
Type of change
How the change has been tested
Updated unit tests.