fix: improve error handling - #3321
Conversation
📝 WalkthroughWalkthroughThe PR bounds numeric RSS entity parsing and specifies radix 10 when converting widget gallery tab keys. ChangesParsing updates
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@examples/rss-reader/src/index.tsx`:
- Around line 30-35: Update both numeric-entity branches in the entity-decoding
logic to validate the complete payload before conversion: stop parsing a fixed
ten-character prefix, reject entities with oversized significant digits or
trailing invalid characters, and only call String.fromCodePoint when the
resulting codePoint is finite and within 0 through 0x10FFFF; otherwise return
match.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 38a7ddf9-3735-49e9-83f4-357ae92cf19f
📒 Files selected for processing (2)
examples/rss-reader/src/index.tsxexamples/widget-gallery/src/index.ts
| const codePoint = Number.parseInt(entity.slice(2, 10), 16); | ||
| return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match; | ||
| } | ||
|
|
||
| if (entity.startsWith('#')) { | ||
| const codePoint = Number.parseInt(entity.slice(1), 10); | ||
| const codePoint = Number.parseInt(entity.slice(1, 10), 10); |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Validate the complete numeric entity before conversion.
slice(..., 10) parses only a prefix, so an oversized entity such as � can be silently decoded from truncated data instead of falling back to match. Number.isFinite also allows values above 0x10FFFF, which can make String.fromCodePoint throw on RSS input. Reject oversized significant payloads and require 0 <= codePoint <= 0x10FFFF in both branches.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@examples/rss-reader/src/index.tsx` around lines 30 - 35, Update both
numeric-entity branches in the entity-decoding logic to validate the complete
payload before conversion: stop parsing a fixed ten-character prefix, reject
entities with oversized significant digits or trailing invalid characters, and
only call String.fromCodePoint when the resulting codePoint is finite and within
0 through 0x10FFFF; otherwise return match.
Summary by CodeRabbit