yesamer commented on code in PR #6871:
URL: https://github.com/apache/incubator-kie/pull/6871#discussion_r3734485294


##########
kie-dmn/kie-dmn-feel/src/main/java/org/kie/dmn/feel/util/XQueryImplUtil.java:
##########
@@ -66,22 +71,38 @@ static <T> T evaluateXQueryExpression(String expression, 
Class<T> expectedTypeRe
          } catch (SaxonApiException e) {
              throw new IllegalArgumentException(e);
          }
-    }
+     }
 
     /**
-     * It replaces all the XML Character References (&, ", ', <, >) in a given 
input string with their "escaping" characters.
-     * This is required to run XPath functions containing XML Character 
References.
-     * @param input A string input representing one of the parameter of 
managed functions
-     * @return A sanitized string
+     * Escapes XML special characters ({@code & " ' < >}) so the value is safe 
to embed
+     * as an XPath string literal. Returns {@code null} unchanged; returns the 
original
+     * reference if no escaping is needed.
      */
     static String escapeXmlCharactersReferencesForXPath(String input) {
-        if (input != null && 
XML_CHARACTER_REFERENCES_PATTERN.matcher(input).find()) {
-            input = input.contains("&") ? input.replace("&", "&amp;") : input;
-            input = input.contains("\"") ? input.replace("\"",  "&quot;") : 
input;
-            input = input.contains("'") ? input.replace("'",  "&apos;") : 
input;
-            input = input.contains("<") ? input.replace("<",  "&lt;") : input;
-            input = input.contains(">") ? input.replace(">",  "&gt;") : input;
+        if (input == null) {
+            return null;
+        }
+        StringBuilder sb = null;

Review Comment:
   @gitgabrio Your suggestion is more elegant, but in terms of performance that 
means to instantiate a StringBuilder for any call, even if is not required 
because the string doesn't contain any special char.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to