mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-30 21:52:50 -07:00
fix(cli): add missing shell metacharacters (\n, \r, \t, \\) to escape regex
This commit is contained in:
@@ -156,6 +156,13 @@ describe('useShellCompletion utilities', () => {
|
||||
expect(escapeShellPath('normal-file.txt')).toBe('normal-file.txt');
|
||||
});
|
||||
|
||||
it('should escape tabs, newlines, carriage returns, and backslashes', () => {
|
||||
expect(escapeShellPath('a\tb')).toBe('a\\\tb');
|
||||
expect(escapeShellPath('a\nb')).toBe('a\\\nb');
|
||||
expect(escapeShellPath('a\rb')).toBe('a\\\rb');
|
||||
expect(escapeShellPath('a\\b')).toBe('a\\\\b');
|
||||
});
|
||||
|
||||
it('should handle empty string', () => {
|
||||
expect(escapeShellPath('')).toBe('');
|
||||
});
|
||||
|
||||
@@ -27,7 +27,7 @@ const FS_COMPLETION_DEBOUNCE_MS = 50;
|
||||
// On Unix, backslash-quote shell metacharacters (spaces, parens, etc.).
|
||||
// On Windows, cmd.exe doesn't use backslash-quoting and `\` is the path
|
||||
// separator, so we leave the path as-is.
|
||||
const UNIX_SHELL_SPECIAL_CHARS = /[ '"()&|;<>!#$`{}[\]*?]/g;
|
||||
const UNIX_SHELL_SPECIAL_CHARS = /[ \t\n\r'"()&|;<>!#$`{}[\]*?\\]/g;
|
||||
|
||||
/**
|
||||
* Escapes special shell characters in a path segment.
|
||||
|
||||
Reference in New Issue
Block a user