-
Notifications
You must be signed in to change notification settings - Fork 229
fix: resolve 4 bugs in termui #3412
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); | ||
|
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. 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Locate and inspect the target file and nearby entity-decoding logic.
if [ -f examples/rss-reader/src/index.tsx ]; then
wc -l examples/rss-reader/src/index.tsx
sed -n '1,80p' examples/rss-reader/src/index.tsx | cat -n
else
echo "target file missing"
fd -a 'index\.tsx$' .
fi
# Check whether String.fromCodePoint raises RangeError at 0x110000 in the sandbox.
node - <<'JS'
const values = [0x10fffe, 0x10ffff, 0x110000, NaN, 1.5];
for (const value of values) {
let out;
try {
out = String.fromCodePoint(value);
} catch (error) {
out = `${error.name}: ${error.message}`;
}
console.log(`${value} -> ${out}`);
}
JSRepository: Karanjot786/TermUI Length of output: 3207 Validate numeric entities before calling
Proposed fix- return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match;
+ return Number.isInteger(codePoint) && codePoint <= 0x10ffff
+ ? String.fromCodePoint(codePoint)
+ : match;🤖 Prompt for AI Agents🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'Files:\n'
fd -a 'index.tsx$' . | sed 's#^\./##' || true
printf '\nTarget excerpt:\n'
if [ -f examples/rss-reader/src/index.tsx ]; then
nl -ba examples/rss-reader/src/index.tsx | sed -n '1,80p'
fi
printf '\nSearch decode/parsing context:\n'
rg -n "parseInt|fromCodePoint|entity|&`#x`|U+|codePoint" examples/rss-reader/src/index.tsx || true
printf '\nBehavioral probe for slice(parseInt):/8-digit boundary:\n'
node - <<'JS'
const cases = [
'&`#x00000041FF`;',
'&`#x10FFFF`;',
'&`#x000110000`;',
'&`#x123456789`;',
];
for (const s of cases) {
const slice = s.slice(2).slice(0, 8);
const codePoint = Number.parseInt(slice, 16);
const full = Number.parseInt(s.slice(2, -1), 16);
console.log(`${s} first8=${slice} value8=${Number(codePoint).toString(16).toUpperCase()} full=${Number(full).toString(16).toUpperCase()} finite=${Number.isFinite(codePoint)} str=${codePoint <= 0x10FFFF && codePoint >= 0 ? String.fromCodePoint(codePoint) : "non-unicode"}`);
}
JSRepository: Karanjot786/TermUI Length of output: 2121 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo 'Target excerpt lines 1-80:'
awk '{printf "%6d %s\n", NR, $0}' examples/rss-reader/src/index.tsx | sed -n '1,80p'
echo
echo 'Search decode/parsing context:'
grep -nE "parseInt|fromCodePoint|entity|&`#x`|U\+|codePoint" examples/rss-reader/src/index.tsx || true
echo
echo 'Behavioral probe for slice(parseInt)/8-digit boundary:'
node - <<'JS'
const cases = [
'&`#x00000041FF`;',
'&`#x10FFFF`;',
'&`#x000110000`;',
'&`#x123456789`;',
];
for (const s of cases) {
const slice = s.slice(2).slice(0, 8);
const codePoint = Number.parseInt(slice, 16);
const full = Number.parseInt(s.slice(2, -1), 16);
console.log(`${s} first8=${slice} value8=${Number(codePoint).toString(16).toUpperCase()} full=${Number(full).toString(16).toUpperCase()} finite=${Number.isFinite(codePoint)} str=${codePoint <= 0x10FFFF && codePoint >= 0 ? String.fromCodePoint(codePoint) : "non-unicode"}`);
}
JSRepository: Karanjot786/TermUI Length of output: 4041 🏁 Script executed: #!/bin/bash
set -euo pipefail
echo 'Behavioral probe for actual source slice and intended bounds:'
node - <<'JS'
const cases = [
['&`#x00000041FF`;', '8 first hex digits'],
['&`#x0000000041FF`;', '8 first hex digits starting after leading x'],
['&`#x10FFFF`;', 'max single code point'],
['&`#x110000`;', 'first invalid code point'],
['&`#xFFFFFFFF`;', 'max 32-bit hex'],
];
for (const [s, note] of cases) {
const sourceSlice = entity => entity.slice(2, 10);
const entity = s.slice(1, -1);
const first8Hex = entity.slice(0, 8);
const codePoint = Number.parseInt(first8Hex, 16);
returnCodePoint = Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : "match";
console.log(`${s} entity=${entity} slice(2,10)=${entity.slice(2,10)} first8Hex=${first8Hex} value=${Number(codePoint).toString(16).toUpperCase()} result=${returnCodePoint}`);
}
JSRepository: Karanjot786/TermUI Length of output: 688 🏁 Script executed: #!/bin/bash
set -euo pipefail
node - <<'JS'
const cases = [
['&`#x00000041FF`;', '8 first hex digits'],
['&`#x0000000041FF`;', '8 first hex digits after leading `#x`'],
['&`#x10FFFF`;', 'max single code point'],
['&`#x110000`;', 'first invalid code point'],
['&`#xFFFFFFFF`;', 'max 32-bit hex'],
['&`#x00000041FF0`;', '9 first hex digits'],
];
function sliceLikeSource(s) {
const entity = s.slice(1, -1);
return entity.slice(2, 10);
}
for (const [s, note] of cases) {
const sliced = sliceLikeSource(s);
const codePoint = Number.parseInt(sliced, 16);
const isValidFiniteString = Number.isFinite(codePoint) && codePoint <= 0x10FFFF && codePoint >= 0;
console.log(JSON.stringify(`${s} -> sliced=${sliced} parse=${sliced ? codePoint.toString(16).toUpperCase() : 'nan'} result=${isValidFiniteString ? String.fromCodePoint(codePoint) : 'match'}`));
}
JSRepository: Karanjot786/TermUI Length of output: 496 Do not slice hex digit strings before parsing.
Proposed fix- const codePoint = Number.parseInt(entity.slice(2, 10), 16);
+ const hexDigits = entity.slice(2, -1);
+ if (hexDigits.length > 8) return match;
+ const codePoint = Number.parseInt(hexDigits, 16);🤖 Prompt for AI Agents |
||
| return Number.isFinite(codePoint) ? String.fromCodePoint(codePoint) : match; | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -44,7 +44,7 @@ export function collectDeps(content: string): string[] { | |||||
| const deps = new Set<string>(); | ||||||
| let m: RegExpExecArray | null; | ||||||
| while ((m = re.exec(content)) !== null) deps.add(m[1]!); | ||||||
| return [...deps].sort(); | ||||||
| return [...deps].sort((a, b) => a - b); | ||||||
|
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 | 🔴 Critical | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
# Confirm the comparator is applied to strings and type-check the project.
rg -n -C 2 'return \[\.\.\.deps\]\.sort' scripts/build-registry.ts
npx tsc --noEmit --pretty falseRepository: Karanjot786/TermUI Length of output: 5860 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'tracked files matching build registry:\n'
git ls-files | rg '(^|/)build-registry(\.test)?\.ts$|tsconfig\.json|package\.json' || true
printf '\nbuild-registry.ts outline:\n'
ast-grep outline scripts/build-registry.ts 2>/dev/null || true
printf '\nrelevant build-registry.ts lines:\n'
sed -n '1,90p' scripts/build-registry.ts
printf '\npackage typescript reference:\n'
node - <<'JS'
const fs = require('node:fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
console.log(JSON.stringify({
deps: Object.fromEntries(Object.entries(pkg.dependencies||{}).filter(([k]) => k === 'typescript')),
devDeps: Object.fromEntries(Object.entries(pkg.devDependencies||{}).filter(([k]) => k === 'typescript'))
}, null, 2));
JS
printf '\ndeclarative type-check equivalent for the comparator expression (non-executable):\n'
node - <<'JS'
// Lightweight probe: JS string subtraction behavior for examples present in dependency names.
const examples = ['react', 'react-dom', 'a', 'z', '1', '10'];
for (const a of examples) {
for (const b of examples) {
const value = a - b;
console.log(JSON.stringify({a,b,result:value,number:a - b}));
}
}
JSRepository: Karanjot786/TermUI Length of output: 10683 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf 'package-manager and bun references:\n'
sed -n '1,80p' package.json
printf '\nlockfile presence:\n'
git ls-files | rg '(^|/)(bun\.lockb?|bun\.lock|package-lock\.json|pnpm-lock\.yaml|yarn\.lock)$' || true
printf '\ntype-check script references:\n'
node - <<'JS'
const fs = require('node:fs');
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
console.log(pkg.scripts?.['type-check'] || pkg.scripts?.['tsc'] || pkg.scripts?.['check'] || JSON.stringify(pkg.scripts, null, 2));
JS
printf '\nrun typed compiler against just the file with project TS, suppressing errors unrelated to this file:\n'
PROJECT_TS="$(npx tsc -v 2>/dev/null | grep 'Version ' | sed 's/Version //')"
echo "project TypeScript version: $PROJECT_TS"
tsc --noEmit scripts/build-registry.ts --strict --module esnext --moduleResolution bundler --lib esnext 2>&1 | sed -n '1,80p'Repository: Karanjot786/TermUI Length of output: 4585 Use a string comparator for dependency names.
Proposed fix- return [...deps].sort((a, b) => a - b);
+ return [...deps].sort((a, b) => a.localeCompare(b));📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||
| } | ||||||
|
|
||||||
| export function toSlug(name: string): string { | ||||||
|
|
||||||
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 | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 291
🏁 Script executed:
Repository: Karanjot786/TermUI
Length of output: 1886
Use valid syntax instead of a trailing postfix assert.
event.ctrl !is parsed asevent.ctrl !and needs an operand, so this branch never registers and theclear-formshortcut stays unreachable. The line also tests exactly the same condition as the Ctrl+C quit guard above it.🤖 Prompt for AI Agents