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

decodeURIComponent should throw URIError for malformed surrogate sequence %ED%BF%BF #4413

Open
ayuan0828 opened this issue Mar 3, 2025 · 1 comment · May be fixed by #4414
Open

decodeURIComponent should throw URIError for malformed surrogate sequence %ED%BF%BF #4413

ayuan0828 opened this issue Mar 3, 2025 · 1 comment · May be fixed by #4414
Labels

Comments

@ayuan0828
Copy link

Description

This test verifies compliance with ECMA-262 requirements on URIError handling. I thought maybe this test case could be added to the test case set?

Testcase

assert.throws(
  URIError,
  function() {
    decodeURIComponent('%ED%BF%BF');
  },
  'Invalid UTF-8 sequence %ED%BF%BF should trigger URIError'
);

Output

Expected behavior: Throw URIError
XS Engine behavior ([Issue #1464](Moddable-OpenSource/moddable#1464)): Returns string "���"

@ptomato
Copy link
Contributor

ptomato commented Mar 3, 2025

Thanks! Please feel free to open a PR with that test case. We probably need a similar one for decodeURI as well.

You could also consider including several types of bad UTF-8 data as detailed in this Stackoverflow post: https://stackoverflow.com/a/1319229/172999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants