Skip to content

Commit

Permalink
BREAKING! Don't parse unicode escapes in PostgreSQL unicode strings a…
Browse files Browse the repository at this point in the history
…nd identifiers

We can't really do that at the CST parser because the escape character
can be defined outside of the string itself.  We could pull it off with
some trickery, but better to leave this out of the scope for this parser.
  • Loading branch information
nene committed Feb 11, 2024
1 parent 47705bd commit f715a15
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 22 deletions.
5 changes: 2 additions & 3 deletions src/parser.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
parseBitBlob,
parseTextBlob,
} from "./utils/blob";
import { parseUnicodeEscapes } from "./utils/unicode";
import {
createBinaryExprChain,
createBinaryExpr,
Expand Down Expand Up @@ -7225,7 +7224,7 @@ string_literal_unicode_single_quoted_qq
return loc({
type: "string_literal",
text: text(),
value: parseUnicodeEscapes(str.value),
value: str.value,
});
}

Expand All @@ -7234,7 +7233,7 @@ string_literal_unicode_double_quoted_qq
return loc({
type: "string_literal",
text: text(),
value: parseUnicodeEscapes(str.value),
value: str.value,
});
}

Expand Down
17 changes: 0 additions & 17 deletions src/utils/unicode.ts

This file was deleted.

2 changes: 1 addition & 1 deletion test/identifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ describe("identifier", () => {
it("parses unicode identifier", () => {
expect(parseExpr(`U&"d\\0061t\\+000061"`)).toMatchInlineSnapshot(`
{
"name": "data",
"name": "d\\0061t\\+000061",
"text": "U&"d\\0061t\\+000061"",
"type": "identifier",
}
Expand Down
2 changes: 1 addition & 1 deletion test/literal/string.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe("string literal", () => {
{
"text": "U&'d\\0061t\\+000061'",
"type": "string_literal",
"value": "data",
"value": "d\\0061t\\+000061",
}
`);
});
Expand Down

0 comments on commit f715a15

Please sign in to comment.