Repository navigation
fix: add .catch() to promise chains - #3283
saurabhhhcodes wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughNumeric HTML/XML entity parsing is bounded in the RSS reader, while keyboard-driven tab selection explicitly parses keys using base 10 in the showcase and widget gallery examples. ChangesExample parsing updates
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 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 the numeric-entity decoding logic around the
codePoint parsing to parse the complete captured digit sequence without bounded
slicing. Return match unless the parsed value is an integer between 0 and
0x10FFFF inclusive, then call String.fromCodePoint only for valid values; apply
this validation to both hexadecimal and decimal entities.
🪄 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: 1224395e-fd11-40bd-9fd9-82115e5d6333
📒 Files selected for processing (3)
examples/rss-reader/src/index.tsxexamples/showcase/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 full numeric entity before decoding.
The bounded slices do not make parsing safe: values such as � or � remain finite but cause String.fromCodePoint to throw, while longer values are silently truncated and can decode to the wrong character. Parse the full captured digits and return match unless the value is an integer in the valid 0..0x10FFFF range.
Suggested fix
- const codePoint = Number.parseInt(entity.slice(2, 10), 16);
- return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
+ const codePoint = Number.parseInt(entity.slice(2), 16);
+ return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10FFFF
+ ? String.fromCodePoint(codePoint)
+ : match;
- const codePoint = Number.parseInt(entity.slice(1, 10), 10);
- return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
+ const codePoint = Number.parseInt(entity.slice(1), 10);
+ return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10FFFF
+ ? String.fromCodePoint(codePoint)
+ : match;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 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); | |
| const codePoint = Number.parseInt(entity.slice(2), 16); | |
| return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10FFFF | |
| ? String.fromCodePoint(codePoint) | |
| : match; | |
| } | |
| if (entity.startsWith('#')) { | |
| const codePoint = Number.parseInt(entity.slice(1), 10); | |
| return Number.isInteger(codePoint) && codePoint >= 0 && codePoint <= 0x10FFFF | |
| ? String.fromCodePoint(codePoint) | |
| : match; |
🤖 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 the
numeric-entity decoding logic around the codePoint parsing to parse the complete
captured digit sequence without bounded slicing. Return match unless the parsed
value is an integer between 0 and 0x10FFFF inclusive, then call
String.fromCodePoint only for valid values; apply this validation to both
hexadecimal and decimal entities.
Summary by CodeRabbit