Skip to content

Commit

Permalink
fix: double slash #deploy_branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lostfields committed Mar 8, 2024
1 parent bd0c1a2 commit 3ba6b93
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/linq/peg/grammar/odata.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ HexDigit
= [a-f] / [A-F] / [0-9]

StringLiteral
= "'" chars:(Escape / ![\\'\n\r] . )* "'"
{ return { type: 'Literal', value: chars.map(l => l[0] || l[1]).join('').replace(/\\\\/g, '\\') } }
= "'" chars:(Escape / !['\n\r] . )* "'"
{ return { type: 'Literal', value: chars.map(l => l[0] || l[1]).join('') } }

ArrayLiteral
= LPAR __ elements:(first:Expression rest:(COMMA __ Expression)* { return buildList(first, rest, 2)})? (COMMA __)? __ RPAR __
Expand Down
6 changes: 3 additions & 3 deletions src/linq/peg/parser/odata-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ function peg$parse(input, options) {
var peg$r11 = /^[+\-]/;
var peg$r12 = /^[pP]/;
var peg$r13 = /^[0-9A-Fa-f]/;
var peg$r14 = /^[\\'\n\r]/;
var peg$r14 = /^['\n\r]/;
var peg$r15 = /^[btnfr"'\\]/;
var peg$r16 = /^[0-3]/;

Expand Down Expand Up @@ -266,7 +266,7 @@ function peg$parse(input, options) {
var peg$e28 = peg$classExpectation(["+", "-"], false, false);
var peg$e29 = peg$classExpectation(["p", "P"], false, false);
var peg$e30 = peg$classExpectation([["0", "9"], ["A", "F"], ["a", "f"]], false, false);
var peg$e31 = peg$classExpectation(["\\", "'", "\n", "\r"], false, false);
var peg$e31 = peg$classExpectation(["'", "\n", "\r"], false, false);
var peg$e32 = peg$anyExpectation();
var peg$e33 = peg$literalExpectation("''", false);
var peg$e34 = peg$literalExpectation("\\", false);
Expand Down Expand Up @@ -438,7 +438,7 @@ function peg$parse(input, options) {
var peg$f26 = function(value) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; };
var peg$f27 = function(first, value, last) { return { type: 'DateLiteral', value: flattenArray(value).join('') }; };
var peg$f28 = function() { return { type: 'NumberLiteral', value: text() }; };
var peg$f29 = function(chars) { return { type: 'Literal', value: chars.map(l => l[0] || l[1]).join('').replace(/\\\\/g, '\\') } };
var peg$f29 = function(chars) { return { type: 'Literal', value: chars.map(l => l[0] || l[1]).join('') } };
var peg$f30 = function(first, rest) { return buildList(first, rest, 2)};
var peg$f31 = function(elements) { return { type: 'ArrayLiteral', elements: elements } };
var peg$currPos = options.peg$currPos | 0;
Expand Down
9 changes: 8 additions & 1 deletion src/test/translator/odata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ describe('When using Translator', () => {
let odata = translator.visit(expr)

chai.expect(odata).to.equal(`contains(customer/name, 'ka\\e')`)
})
})

it('should handle escape of character \\ twice', () => {
let expr = visitor.parseOData(`contains(customer/name, 'ka\\\\e')`)
let odata = translator.visit(expr)

chai.expect(odata).to.equal(`contains(customer/name, 'ka\\\\e')`)
})

it('should handle unicode if that is a thing', () => {
let expr = visitor.parseOData(`contains(customer/name, 'ka\\u1128')`)
Expand Down

0 comments on commit 3ba6b93

Please sign in to comment.