fix: handle URIError in decodePathname for malformed percent-encoding (#1361) - #1363
fix: handle URIError in decodePathname for malformed percent-encoding (#1361)#1363guoyangzhen wants to merge 1 commit into
Conversation
decodeURI throws URIError on malformed percent-encoded paths (e.g., %XX). Wrap in try/catch to return original pathname on decode failure. Fixes h3js#1361
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughUpdates path utility functions in Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
⚔️ Resolve merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🔗 Linked issue
Fixes #1361
📝 Description
decodePathnamecallsdecodeURI()which throwsURIErroron malformed percent-encoded paths (e.g., incomplete sequences like%XXor invalid UTF-8). Since this runs duringH3Eventconstruction, the request fails before any app-level error handling can run.This was a breaking change between rc.16 and rc.19 that blocked TanStack Router's upgrade (TanStack/router#7044).
🔄 Changes
Wrap the
decodeURIcall in a try/catch block that returns the original pathname on decode failure:This is the same approach suggested by the issue reporter and matches the defensive pattern used elsewhere in the codebase.
Summary by CodeRabbit
Bug Fixes
Chores