Mercurial > hg > orthanc
diff OrthancServer/Sources/Search/ISqlLookupFormatter.cpp @ 4817:b8fcd331b4b3
added ISqlLookupFormatter::IsEscapeBrackets()
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Nov 2021 13:09:15 +0100 |
parents | d9473bd5ed43 |
children | 70d2a97ca8cb 7053502fbf97 |
line wrap: on
line diff
--- a/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Wed Nov 24 18:03:35 2021 +0100 +++ b/OrthancServer/Sources/Search/ISqlLookupFormatter.cpp Thu Nov 25 13:09:15 2021 +0100 @@ -79,7 +79,8 @@ static bool FormatComparison(std::string& target, ISqlLookupFormatter& formatter, const DatabaseConstraint& constraint, - size_t index) + size_t index, + bool escapeBrackets) { std::string tag = "t" + boost::lexical_cast<std::string>(index); @@ -196,6 +197,14 @@ { escaped += "\\\\"; } + else if (escapeBrackets && value[i] == '[') + { + escaped += "\\["; + } + else if (escapeBrackets && value[i] == ']') + { + escaped += "\\]"; + } else { escaped += value[i]; @@ -303,6 +312,8 @@ assert(upperLevel <= queryLevel && queryLevel <= lowerLevel); + const bool escapeBrackets = formatter.IsEscapeBrackets(); + std::string joins, comparisons; size_t count = 0; @@ -311,7 +322,7 @@ { std::string comparison; - if (FormatComparison(comparison, formatter, lookup[i], count)) + if (FormatComparison(comparison, formatter, lookup[i], count, escapeBrackets)) { std::string join; FormatJoin(join, lookup[i], count);