mirror of
https://github.com/stablyai/orca.git
synced 2026-11-02 01:57:57 +00:00
* fix(terminal): refuse an OSC 7 folder with a control character; both parsers agree on % A decoded OSC 7 folder containing a C0 control (NUL, newline, ESC...) is now refused by both the daemon's and the renderer's parser, keeping the last good folder: node-pty silently truncates a cwd at NUL and execFile can throw on one. The renderer now also treats a `%` not followed by two hex digits as a literal `%`, as the daemon does since nushell support, so the two agree. Both use one small shared module for these rules; the parsers otherwise stay separate (the daemon's resolves dot segments and hosts through the URL parser, the renderer's does not). * fix(terminal): refuse only NUL in an OSC 7 folder; both parsers keep raw spaces and controls - Only NUL (raw or %00) is refused now. Tab, newline, ESC and other control characters are legal in Linux and macOS folder names and decode as before; refusing them left split, new terminal and restore in a stale folder. - The daemon encodes every raw C0 byte and space in the path before the URL parser, which would otherwise strip a raw tab or newline and trim a trailing space or NUL, naming another folder. The renderer's regex now reads a raw newline as part of the path. Both parsers now give /tmp/a<TAB>b, keep /tmp/a 's trailing space, and refuse a raw NUL. - One shared case list runs against both parsers. The 104-case snapshot of existing senders is byte-identical.
15 lines
602 B
TypeScript
15 lines
602 B
TypeScript
// Rules both OSC 7 parsers (the daemon's and the renderer's) share, so they agree on a folder.
|
|
|
|
/** A `%` not followed by two hex digits is a literal `%` (nushell sends folder names unencoded). */
|
|
export function escapeLiteralPercent(text: string): string {
|
|
return text.replace(/%(?![0-9A-Fa-f]{2})/g, '%25')
|
|
}
|
|
|
|
/**
|
|
* No path can contain NUL, and node-pty silently truncates a cwd at one while execFile can throw;
|
|
* refusing keeps the last good folder. Other control characters are legal in folder names.
|
|
*/
|
|
export function hasNulCharacter(path: string): boolean {
|
|
return path.includes('\0')
|
|
}
|