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

Support %-encoded characters in DID URL #1496

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

UMR1352
Copy link
Contributor

@UMR1352 UMR1352 commented Jan 6, 2025

Description of change

Allow the use of %-encoded characters in DID URLs.

Links to any relevant issues

Closes #1492

Type of change

  • Bug fix (a non-breaking change which fixes an issue)
  • Enhancement (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Fix

How the change has been tested

Updated unit tests.

@UMR1352 UMR1352 added Bug Something isn't working. Rust Related to the core Rust code. Becomes part of the Rust changelog. Patch Change without affecting the API that requires a patch release. Part of "Patch" section in changelog labels Jan 6, 2025
@UMR1352 UMR1352 self-assigned this Jan 6, 2025
@UMR1352 UMR1352 requested a review from a team as a code owner January 6, 2025 13:40
identity_did/src/did_url.rs Outdated Show resolved Hide resolved
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())
Copy link
Contributor

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)

@UMR1352 UMR1352 requested a review from wulfraem January 13, 2025 16:25
@UMR1352 UMR1352 requested a review from wulfraem January 14, 2025 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working. Patch Change without affecting the API that requires a patch release. Part of "Patch" section in changelog Rust Related to the core Rust code. Becomes part of the Rust changelog.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DIDUrl implementation doesn't support %-encoded path and fragment
2 participants