Skip to content

fix: improve error handling - #3321

Open
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-97973
Open

fix: improve error handling#3321
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-97973

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved decoding of numeric HTML entities, including hexadecimal and decimal formats.
    • Improved keyboard-based tab switching in the widget gallery for more reliable numeric key handling.

@github-actions github-actions Bot added area:examples Example apps. type:bug +10 pts. Bug fix. labels Jul 30, 2026
@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR bounds numeric RSS entity parsing and specifies radix 10 when converting widget gallery tab keys.

Changes

Parsing updates

Layer / File(s) Summary
Bound RSS numeric entity parsing
examples/rss-reader/src/index.tsx
decodeEntities parses bounded hexadecimal and decimal entity payloads before converting them to codepoints.
Explicit decimal tab key parsing
examples/widget-gallery/src/index.ts
WidgetGalleryApp.handleKey uses radix 10 when parsing numeric tab keys.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning No pull request description was added, so the required template sections are missing. Add the full template sections, especially Description, Related Issue, Which package(s)?, and Type of Change.
Title check ❓ Inconclusive The title is related to parsing robustness, but it is too generic to clearly describe the actual code changes. Use a more specific title like fix: make entity and key parsing more robust.
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 48f63a1 and 2e09d86.

📒 Files selected for processing (2)
  • examples/rss-reader/src/index.tsx
  • examples/widget-gallery/src/index.ts

Comment on lines +30 to +35
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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Validate the complete numeric entity before conversion.

slice(..., 10) parses only a prefix, so an oversized entity such as &#x000041000000; 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:examples Example apps. type:bug +10 pts. Bug fix.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant