mirror of
https://github.com/earendil-works/pi.git
synced 2026-06-18 15:54:04 +08:00
refactor(tui): Use explicit charCode check for unicode filtering
- Use 'charCodeAt(0) >= 32' instead of open 'else' in handleInput() - Use same filter in handlePaste() for consistency - Prevents control characters while allowing all unicode - More explicit and safer than accepting everything
This commit is contained in:
@@ -333,8 +333,8 @@ export class Editor implements Component {
|
||||
// Left
|
||||
this.moveCursor(0, -1);
|
||||
}
|
||||
// Regular characters (printable ASCII)
|
||||
else {
|
||||
// Regular characters (printable characters and unicode, but not control characters)
|
||||
else if (data.charCodeAt(0) >= 32) {
|
||||
this.insertCharacter(data);
|
||||
}
|
||||
}
|
||||
@@ -472,7 +472,7 @@ export class Editor implements Component {
|
||||
// Filter out non-printable characters except newlines
|
||||
const filteredText = tabExpandedText
|
||||
.split("")
|
||||
.filter((char) => char === "\n" || char.length > 0)
|
||||
.filter((char) => char === "\n" || char.charCodeAt(0) >= 32)
|
||||
.join("");
|
||||
|
||||
// Split into lines
|
||||
|
||||
Reference in New Issue
Block a user