Skip to content

Commit

Permalink
add different types of quotes to parser
Browse files Browse the repository at this point in the history
  • Loading branch information
289Adam289 committed Dec 19, 2024
1 parent 31adaa8 commit e67cdb6
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
40 changes: 20 additions & 20 deletions src/libs/SearchParser/autocompleteParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,13 +212,13 @@ function peg$parse(input, options) {
var peg$c34 = ">";
var peg$c35 = "<=";
var peg$c36 = "<";
var peg$c37 = "\"";

var peg$r0 = /^[:=]/;
var peg$r1 = /^[^ ,"\t\n\r]/;
var peg$r2 = /^[^"\r\n]/;
var peg$r3 = /^[^ ,\t\n\r]/;
var peg$r4 = /^[ \t\r\n]/;
var peg$r1 = /^[^ ,"\u201D\u201C\t\n\r]/;
var peg$r2 = /^["\u201C-\u201D]/;
var peg$r3 = /^[^"\u201D\u201C\r\n]/;
var peg$r4 = /^[^ ,\t\n\r]/;
var peg$r5 = /^[ \t\r\n]/;

var peg$e0 = peg$literalExpectation(",", false);
var peg$e1 = peg$otherExpectation("key");
Expand Down Expand Up @@ -261,9 +261,9 @@ function peg$parse(input, options) {
var peg$e38 = peg$literalExpectation("<=", false);
var peg$e39 = peg$literalExpectation("<", false);
var peg$e40 = peg$otherExpectation("quote");
var peg$e41 = peg$classExpectation([" ", ",", "\"", "\t", "\n", "\r"], true, false);
var peg$e42 = peg$literalExpectation("\"", false);
var peg$e43 = peg$classExpectation(["\"", "\r", "\n"], true, false);
var peg$e41 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r"], true, false);
var peg$e42 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false);
var peg$e43 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false);
var peg$e44 = peg$classExpectation([" ", ",", "\t", "\n", "\r"], true, false);
var peg$e45 = peg$otherExpectation("word");
var peg$e46 = peg$otherExpectation("whitespace");
Expand Down Expand Up @@ -1418,8 +1418,8 @@ function peg$parse(input, options) {
if (peg$silentFails === 0) { peg$fail(peg$e41); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
s2 = peg$c37;
s2 = input.charAt(peg$currPos);
if (peg$r2.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand All @@ -1428,7 +1428,7 @@ function peg$parse(input, options) {
if (s2 !== peg$FAILED) {
s3 = [];
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
if (peg$r3.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
Expand All @@ -1437,15 +1437,15 @@ function peg$parse(input, options) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
if (peg$r3.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e43); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
s4 = peg$c37;
s4 = input.charAt(peg$currPos);
if (peg$r2.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
Expand All @@ -1454,7 +1454,7 @@ function peg$parse(input, options) {
if (s4 !== peg$FAILED) {
s5 = [];
s6 = input.charAt(peg$currPos);
if (peg$r3.test(s6)) {
if (peg$r4.test(s6)) {
peg$currPos++;
} else {
s6 = peg$FAILED;
Expand All @@ -1463,7 +1463,7 @@ function peg$parse(input, options) {
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = input.charAt(peg$currPos);
if (peg$r3.test(s6)) {
if (peg$r4.test(s6)) {
peg$currPos++;
} else {
s6 = peg$FAILED;
Expand Down Expand Up @@ -1496,7 +1496,7 @@ function peg$parse(input, options) {
s0 = peg$currPos;
s1 = [];
s2 = input.charAt(peg$currPos);
if (peg$r3.test(s2)) {
if (peg$r4.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand All @@ -1506,7 +1506,7 @@ function peg$parse(input, options) {
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = input.charAt(peg$currPos);
if (peg$r3.test(s2)) {
if (peg$r4.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand Down Expand Up @@ -1548,7 +1548,7 @@ function peg$parse(input, options) {
peg$silentFails++;
s0 = [];
s1 = input.charAt(peg$currPos);
if (peg$r4.test(s1)) {
if (peg$r5.test(s1)) {
peg$currPos++;
} else {
s1 = peg$FAILED;
Expand All @@ -1557,7 +1557,7 @@ function peg$parse(input, options) {
while (s1 !== peg$FAILED) {
s0.push(s1);
s1 = input.charAt(peg$currPos);
if (peg$r4.test(s1)) {
if (peg$r5.test(s1)) {
peg$currPos++;
} else {
s1 = peg$FAILED;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/SearchParser/baseRules.peggy
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ operator "operator"
/ "<" { return "lt"; }

quotedString "quote"
= start:[^ ,"\t\n\r]* "\"" inner:[^"\r\n]* "\"" end:[^ ,\t\n\r]* {
= start:[^ ,"”“\t\n\r]* ("“" / "\"" / "”") inner:[^"”“\r\n]* ("“" / "\"" / "”") end:[^ ,\t\n\r]* {
return [...start, '"', ...inner, '"', ...end].join("");
}

Expand Down
40 changes: 20 additions & 20 deletions src/libs/SearchParser/searchParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,14 +217,14 @@ function peg$parse(input, options) {
var peg$c34 = ">";
var peg$c35 = "<=";
var peg$c36 = "<";
var peg$c37 = "\"";

var peg$r0 = /^[^ \t\r\n]/;
var peg$r1 = /^[:=]/;
var peg$r2 = /^[^ ,"\t\n\r]/;
var peg$r3 = /^[^"\r\n]/;
var peg$r4 = /^[^ ,\t\n\r]/;
var peg$r5 = /^[ \t\r\n]/;
var peg$r2 = /^[^ ,"\u201D\u201C\t\n\r]/;
var peg$r3 = /^["\u201C-\u201D]/;
var peg$r4 = /^[^"\u201D\u201C\r\n]/;
var peg$r5 = /^[^ ,\t\n\r]/;
var peg$r6 = /^[ \t\r\n]/;

var peg$e0 = peg$classExpectation([" ", "\t", "\r", "\n"], true, false);
var peg$e1 = peg$otherExpectation("key");
Expand Down Expand Up @@ -269,9 +269,9 @@ function peg$parse(input, options) {
var peg$e40 = peg$literalExpectation("<=", false);
var peg$e41 = peg$literalExpectation("<", false);
var peg$e42 = peg$otherExpectation("quote");
var peg$e43 = peg$classExpectation([" ", ",", "\"", "\t", "\n", "\r"], true, false);
var peg$e44 = peg$literalExpectation("\"", false);
var peg$e45 = peg$classExpectation(["\"", "\r", "\n"], true, false);
var peg$e43 = peg$classExpectation([" ", ",", "\"", "\u201D", "\u201C", "\t", "\n", "\r"], true, false);
var peg$e44 = peg$classExpectation(["\"", ["\u201C", "\u201D"]], false, false);
var peg$e45 = peg$classExpectation(["\"", "\u201D", "\u201C", "\r", "\n"], true, false);
var peg$e46 = peg$classExpectation([" ", ",", "\t", "\n", "\r"], true, false);
var peg$e47 = peg$otherExpectation("word");
var peg$e48 = peg$otherExpectation("whitespace");
Expand Down Expand Up @@ -1616,8 +1616,8 @@ function peg$parse(input, options) {
if (peg$silentFails === 0) { peg$fail(peg$e43); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
s2 = peg$c37;
s2 = input.charAt(peg$currPos);
if (peg$r3.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand All @@ -1626,7 +1626,7 @@ function peg$parse(input, options) {
if (s2 !== peg$FAILED) {
s3 = [];
s4 = input.charAt(peg$currPos);
if (peg$r3.test(s4)) {
if (peg$r4.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
Expand All @@ -1635,15 +1635,15 @@ function peg$parse(input, options) {
while (s4 !== peg$FAILED) {
s3.push(s4);
s4 = input.charAt(peg$currPos);
if (peg$r3.test(s4)) {
if (peg$r4.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e45); }
}
}
if (input.charCodeAt(peg$currPos) === 34) {
s4 = peg$c37;
s4 = input.charAt(peg$currPos);
if (peg$r3.test(s4)) {
peg$currPos++;
} else {
s4 = peg$FAILED;
Expand All @@ -1652,7 +1652,7 @@ function peg$parse(input, options) {
if (s4 !== peg$FAILED) {
s5 = [];
s6 = input.charAt(peg$currPos);
if (peg$r4.test(s6)) {
if (peg$r5.test(s6)) {
peg$currPos++;
} else {
s6 = peg$FAILED;
Expand All @@ -1661,7 +1661,7 @@ function peg$parse(input, options) {
while (s6 !== peg$FAILED) {
s5.push(s6);
s6 = input.charAt(peg$currPos);
if (peg$r4.test(s6)) {
if (peg$r5.test(s6)) {
peg$currPos++;
} else {
s6 = peg$FAILED;
Expand Down Expand Up @@ -1694,7 +1694,7 @@ function peg$parse(input, options) {
s0 = peg$currPos;
s1 = [];
s2 = input.charAt(peg$currPos);
if (peg$r4.test(s2)) {
if (peg$r5.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand All @@ -1704,7 +1704,7 @@ function peg$parse(input, options) {
while (s2 !== peg$FAILED) {
s1.push(s2);
s2 = input.charAt(peg$currPos);
if (peg$r4.test(s2)) {
if (peg$r5.test(s2)) {
peg$currPos++;
} else {
s2 = peg$FAILED;
Expand Down Expand Up @@ -1746,7 +1746,7 @@ function peg$parse(input, options) {
peg$silentFails++;
s0 = [];
s1 = input.charAt(peg$currPos);
if (peg$r5.test(s1)) {
if (peg$r6.test(s1)) {
peg$currPos++;
} else {
s1 = peg$FAILED;
Expand All @@ -1755,7 +1755,7 @@ function peg$parse(input, options) {
while (s1 !== peg$FAILED) {
s0.push(s1);
s1 = input.charAt(peg$currPos);
if (peg$r5.test(s1)) {
if (peg$r6.test(s1)) {
peg$currPos++;
} else {
s1 = peg$FAILED;
Expand Down
3 changes: 1 addition & 2 deletions src/libs/SearchQueryUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ const UserFriendlyKeyMap: Record<SearchFilterKey | typeof CONST.SEARCH.SYNTAX_RO
* Returns string value wrapped in quotes "", if the value contains special characters.
*/
function sanitizeSearchValue(str: string) {
const regexp = /[^A-Za-z0-9_@./#&+\-\\';,"]/g;
if (regexp.test(str)) {
if (str.includes(' ')) {
return `"${str}"`;
}
return str;
Expand Down

0 comments on commit e67cdb6

Please sign in to comment.