Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix(serve-static): add error handler for decoding uri components #208

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

alumowa
Copy link
Contributor

@alumowa alumowa commented Oct 25, 2024

This PR adds an error handler for potentially thrown URIError during decodeURIComponent that should result in a HTTP 404 rather than an HTTP 500 error.

This may happen if the encoded uri component contains an invalid sequence encoding:

URIError
Thrown if encodedURI contains a % not followed by two hexadecimal digits, or if the escape sequence does not encode a valid UTF-8 character.

Also added a test for this case 👓

@alumowa alumowa force-pushed the handle-URIError-during-decode branch from 9b2aca8 to e3b3e84 Compare October 25, 2024 09:49
Copy link
Member

@yusukebe yusukebe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@yusukebe
Copy link
Member

Hi @alumowa

Thank you for the PR. I also think it's okay to return a 404. I'll merge it and release a new version.

@yusukebe yusukebe merged commit 3dcf537 into honojs:main Oct 28, 2024
3 checks passed
@alumowa alumowa deleted the handle-URIError-during-decode branch October 28, 2024 09:47
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants