Support escaping single and double quotes in Deck Editor Search Regex Strings (#4948)

- Fix #4946
This commit is contained in:
Zach H 2023-12-09 00:51:54 -05:00 committed by GitHub
parent 4b8e47d079
commit 519531f3a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -42,9 +42,10 @@ ColorQuery <- [cC] 'olor'? <[iI]?> <[:!]> ColorEx*
FieldQuery <- String [:] RegexString / String ws? NumericExpression FieldQuery <- String [:] RegexString / String ws? NumericExpression
NonQuote <- !["]. NonDoubleQuoteUnlessEscaped <- !["]. / '\"'.
UnescapedStringListPart <- ![":<>=! ]. NonSingleQuoteUnlessEscaped <- ![']. / "\'".
String <- UnescapedStringListPart+ / ["] <NonQuote*> ["] UnescapedStringListPart <- !['":<>=! ].
String <- UnescapedStringListPart+ / ["] <NonDoubleQuoteUnlessEscaped*> ["] / ['] <NonSingleQuoteUnlessEscaped*> [']
StringValue <- String / [(] StringList [)] StringValue <- String / [(] StringList [)]
StringList <- StringListString (ws? [,] ws? StringListString)* StringList <- StringListString (ws? [,] ws? StringListString)*
StringListString <- UnescapedStringListPart+ StringListString <- UnescapedStringListPart+
@ -56,7 +57,7 @@ CompactStringSet <- StringListString ([,+] StringListString)+
NumericExpression <- NumericOperator ws? NumericValue NumericExpression <- NumericOperator ws? NumericValue
NumericOperator <- [=:] / <[><!][=]?> NumericOperator <- [=:] / <[><!][=]?>
NumericValue <- [0-9]+ NumericValue <- [0-9]+
)"); )");
@ -242,7 +243,12 @@ static void setupParserRules()
search["RegexString"] = [](const peg::SemanticValues &sv) -> StringMatcher { search["RegexString"] = [](const peg::SemanticValues &sv) -> StringMatcher {
auto target = sv[0].get<QString>(); auto target = sv[0].get<QString>();
return [=](const QString &s) { return s.QString::contains(target, Qt::CaseInsensitive); }; return [=](const QString &s) {
auto sanitizedTarget = QString(target);
sanitizedTarget.replace("\\\"", "\"");
sanitizedTarget.replace("\\'", "'");
return s.QString::contains(sanitizedTarget, Qt::CaseInsensitive);
};
}; };
search["OracleQuery"] = [](const peg::SemanticValues &sv) -> Filter { search["OracleQuery"] = [](const peg::SemanticValues &sv) -> Filter {