Skip to content

fix: add .catch() to promise chains - #3283

Closed
saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-p-5932
Closed

saurabhhhcodes wants to merge 1 commit into
Karanjot786:mainfrom
saurabhhhcodes:fix/termui-p-5932

Conversation

@saurabhhhcodes

@saurabhhhcodes saurabhhhcodes commented Jul 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Bug Fixes
    • Improved RSS feed handling for numeric HTML/XML entities, including malformed or unusually long values.
    • Improved keyboard-based tab switching in showcase and widget gallery examples for more consistent number handling.

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

coderabbitai Bot commented Jul 29, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Numeric 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.

Changes

Example parsing updates

Layer / File(s) Summary
Bound numeric entity parsing
examples/rss-reader/src/index.tsx
Hexadecimal and decimal entity parsing now uses bounded substrings before converting numeric code points.
Explicit base-10 tab parsing
examples/showcase/src/index.tsx, examples/widget-gallery/src/index.ts
Tab-switching handlers now call parseInt with radix 10. מכל

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: karanjot786

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (3 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions promise chains, but the changes only affect entity decoding and key parsing in example apps. Rename the title to match the actual changes, e.g. describe the numeric entity parsing and explicit radix handling updates.
Description check ⚠️ Warning No PR description was provided, so the required template sections are completely missing. Add the full template sections: Description, Related Issue, Which package(s), Type of Change, Checklist, GSSoC Participation, screenshots, and reviewer notes.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
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 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

📥 Commits

Reviewing files that changed from the base of the PR and between 48f63a1 and 0a91606.

📒 Files selected for processing (3)
  • examples/rss-reader/src/index.tsx
  • examples/showcase/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 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.

Suggested change
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.

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