Commit 71bdcd1f authored by Marco Libanori's avatar Marco Libanori
Browse files

[KNOWAGE-6790] Correctly manage escapes in LOV execution

parent 5efbc138
......@@ -266,7 +266,7 @@ public class StringUtilities {
if (slashEIndex == -1)
return "\\Q" + s + "\\E";
StringBuffer sb = new StringBuffer(s.length() * 2);
StringBuilder sb = new StringBuilder(s.length() * 2);
sb.append("\\Q");
slashEIndex = 0;
int current = 0;
......@@ -463,6 +463,8 @@ public class StringUtilities {
replacement = "'" + replacement;
if (!replacement.endsWith("'"))
replacement = replacement + "'";
replacement = escapeInternalQuotes(replacement);
}
attribute = quote(attribute);
......@@ -475,6 +477,14 @@ public class StringUtilities {
}
private static String escapeInternalQuotes(String replacement) {
return new StringBuilder()
.append(replacement.charAt(0))
.append(replacement.substring(1, replacement.length() - 1).replaceAll("'","''"))
.append(replacement.charAt(replacement.length() - 1))
.toString();
}
/**
* Substitutes parameters with sintax "$P{parameter_name}" whose value is set in the map. This is only for dataset, had to duplicate to handle null values,
* in case ogf null does not throw an exception but substitute null!
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment