-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3487
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -27,7 +27,7 @@ function decodeEntities(value: string): string { | |||||||||||||||||
|
|
||||||||||||||||||
| return value.replace(/&(#x?[0-9a-fA-F]+|[a-zA-Z]+);/g, (match, entity: string) => { | ||||||||||||||||||
| if (entity.startsWith('#x')) { | ||||||||||||||||||
| const codePoint = Number.parseInt(entity.slice(2), 16); | ||||||||||||||||||
| const codePoint = Number.parseInt(entity.slice(2, 10), 16); | ||||||||||||||||||
| return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match; | ||||||||||||||||||
|
Comment on lines
+30
to
31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Reject overlong and out-of-range entities instead of truncating them.
Proposed fix- const codePoint = Number.parseInt(entity.slice(2, 10), 16);
- return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
+ const digits = entity.slice(2);
+ if (digits.length > 8) return match;
+ const codePoint = Number.parseInt(digits, 16);
+ return Number.isFinite(codePoint) && codePoint <= 0x10FFFF
+ ? String.fromCodePoint(codePoint)
+ : match;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Scale the epsilon to the percentage value.
At Line 185, the calculation adds
Number.EPSILONafter multiplying by 100. That epsilon can be too small to change values near28.5. For example,0.285 * 100can produce28.499999999999996, so the label can still display28%instead of29%.Use an epsilon scaled for the percentage range and add a boundary test.
Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents