-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NLS: escape backslashes in query string (#6585)
In addition to quotes, we also need to escape backslashes in the original query string. This is because in search filters like `content:"..."`, backslashes are used to indicate control sequences. ## Test plan Added new unit test.
- Loading branch information
1 parent
ddb6e7c
commit e5425fd
Showing
3 changed files
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
vscode/src/chat/chat-view/handlers/__tests__/SearchHandler.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { describe, expect, it } from 'vitest' | ||
import { escapeNLSQuery } from '../SearchHandler' | ||
|
||
describe('escapeNLSQuery', () => { | ||
it('escapes backslashes', () => { | ||
expect(escapeNLSQuery('path\\to\\file')).toBe('path\\\\to\\\\file') | ||
}) | ||
|
||
it('escapes double quotes', () => { | ||
expect(escapeNLSQuery(`say "hello"`)).toBe(`say \\"hello\\"`) | ||
}) | ||
|
||
it('escapes escaped quotes', () => { | ||
expect(escapeNLSQuery(`c:\\path\\"file"`)).toBe(`c:\\\\path\\\\\\"file\\"`) | ||
}) | ||
}) |