- Notifications
You must be signed in to change notification settings - Fork689
Fix backslash escape handling in SQL string literals with performance optimization#2335
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
Copilot wants to merge11 commits intodevelopChoose a base branch fromcopilot/fix-ascii-escapes
base:develop
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes from1 commit
Commits
Show all changes
11 commits Select commitHold shift + click to select a range
8b5606e Initial plan
Copilot323e526 Fix ASCII backslash escaping in SQL string literals
Copilot4d68d1f Revert unintended package.json changes
Copilot03e5382 Optimize regex patterns by pre-compiling them
Copilot927df05 Revert unintended yarn.lock registry URL changes
Copilot3e12c42 Add tests for edge case: escaped backslash followed by escaped quote
Copilot20eedaf Revert yarn.lock to avoid unintended changes
Copilot0c8c2ac Fix backslash replacement to use String.fromCharCode for proper escaping
Copilotedcea84 Add comprehensive quote and backslash escaping tests
Copilot8235c49 Add double quote and parameterized query tests
Copilot472f3a8 merge2
mathiasrwFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
Add tests for edge case: escaped backslash followed by escaped quote
Added comprehensive tests to verify the parser correctly handles the edge case where an escaped backslash is followed by an escaped quote. The implementation correctly processes '\\' (backslash + quote using SQL quote doubling) and '\\\\' (two backslashes + quote).Co-authored-by: mathiasrw <1063454+mathiasrw@users.noreply.github.com>
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
21 changes: 21 additions & 0 deletionstest/test489.js
mathiasrw marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. |
This file contains hidden or 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 |
|---|---|---|
| @@ -18,4 +18,25 @@ describe('Test 489 - ASCII with backslash character', function () { | ||
| var res = alasql("VALUE OF SELECT '\\\\'"); | ||
| assert.equal(res, '\\'); | ||
| }); | ||
| it('D) Escaped backslash followed by escaped quote (edge case)', function () { | ||
| // In SQL: '\\'' means backslash followed by quote | ||
| // \\ = one backslash, '' = one quote (SQL quote doubling) | ||
| var res = alasql("VALUE OF SELECT '\\\\'''"); | ||
| assert.equal(res.length, 2); | ||
| assert.equal(res.charCodeAt(0), 92); // backslash | ||
| assert.equal(res.charCodeAt(1), 39); // quote | ||
| assert.equal(res, "\\'"); | ||
| }); | ||
| it('E) Multiple backslashes followed by quote', function () { | ||
| // In SQL: '\\\\'' means two backslashes followed by quote | ||
| // \\\\ = two backslashes, '' = one quote | ||
| var res = alasql("VALUE OF SELECT '\\\\\\\\'''"); | ||
| assert.equal(res.length, 3); | ||
| assert.equal(res.charCodeAt(0), 92); // backslash | ||
| assert.equal(res.charCodeAt(1), 92); // backslash | ||
| assert.equal(res.charCodeAt(2), 39); // quote | ||
| assert.equal(res, "\\\\'"); | ||
mathiasrw marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.