Skip to content

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 a team and chenyan-dfinity 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
@viviveevee viviveevee 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
@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
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.

3 participants