Skip to content

fix: url decoding in ic-certified-assets #3767

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

Merged
merged 5 commits into from
Jun 3, 2024
Merged

fix: url decoding in ic-certified-assets #3767

merged 5 commits into from
Jun 3, 2024

Conversation

raymondk
Copy link
Contributor

@raymondk raymondk commented May 23, 2024

Description

The url_decode function in ic-certified-assets didn't correctly decode some special characters.
The code has been changed to decode the "percent strings" to bytes instead of char and then convert the bytes to utf8 strings.

This change is using https://crates.io/crates/percent-encoding - We can then reuse the same library in the response verification library. The crate complies with: https://url.spec.whatwg.org/#percent-decode

Fixes # (SDK-1412)

How Has This Been Tested?

Fixed the existing unit tests and added new unit tests.

One of the tests was broken:

fn main() {
    let c = char::from(230 as u8);
    println!("This is from a char:` {}`", c);
    
    let s = String::from_utf8([230 as u8].to_vec());
    println!("This from a bytes: `{}`", s.unwrap_or(String::from("ERROR")));
}

Outputs:

This is from a char:`æ`
This from a bytes: `ERROR`

The correct encoding for æ is over two bytes %C3%A6

Checklist:

  • The title of this PR complies with Conventional Commits.
  • I have edited the CHANGELOG accordingly.
  • I have made corresponding changes to the documentation.

@raymondk raymondk requested review from chenyan-dfinity and a team as code owners May 23, 2024 21:54
@raymondk raymondk requested a review from nathanosdev May 23, 2024 21:55
@raymondk raymondk force-pushed the raymond/sdk-1412 branch from 6f333c2 to 69bf530 Compare May 29, 2024 20:45
@sesi200 sesi200 requested a review from a team as a code owner May 31, 2024 12:17
@raymondk raymondk force-pushed the raymond/sdk-1412 branch from 5d36c2f to 8cf3e77 Compare June 3, 2024 13:42
@raymondk raymondk merged commit e28a878 into master Jun 3, 2024
286 checks passed
@raymondk raymondk deleted the raymond/sdk-1412 branch June 3, 2024 17:55
rikonor pushed a commit that referenced this pull request Feb 3, 2025
Co-authored-by: Severin Siffert <severin.siffert@dfinity.org>
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.

4 participants