Skip to content

Commit

Permalink
Merge pull request #3789 from GDLMadushanka/dssEsc
Browse files Browse the repository at this point in the history
Avoid escape XML when creating params
  • Loading branch information
GDLMadushanka authored Nov 25, 2024
2 parents b9d24d3 + 50427b1 commit d60355d
Showing 1 changed file with 0 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -298,10 +298,6 @@ private void addParams(Param param, OMElement payload, MessageContext msgCtx) {
paramValue = param.getParamValue();
} else if (param.getParamExpression() != null) {
paramValue = param.getParamExpression().stringValueOf(msgCtx);
if (DataServiceCallMediatorConstants.XML_TYPE.equals(param.getEvaluator()) &&
!isJson(paramValue.trim(), param.getParamExpression())) {
paramValue = escapeXMLEnvelope(msgCtx, paramValue);
}
}
omElement.setText(paramValue);
payload.addChild(omElement);
Expand All @@ -315,33 +311,6 @@ private boolean isJson(String value, SynapsePath expression) {
|| value.trim().charAt(0) == '[') && expression.getPathType().equals(SynapsePath.JSON_PATH);
}

/**
* Escapes XML special characters
*
* @param msgCtx Message Context
* @param value XML String which needs to be escaped
* @return XML special char escaped string
*/
private String escapeXMLEnvelope(MessageContext msgCtx, String value) {
String xmlVersion = "1.0"; //Default is set to 1.0

try {
xmlVersion = checkXMLVersion(msgCtx);
} catch (IOException e) {
log.error("Error reading message envelope", e);
} catch (SAXException e) {
log.error("Error parsing message envelope", e);
} catch (ParserConfigurationException e) {
log.error("Error building message envelope document", e);
}

if ("1.1".equals(xmlVersion)) {
return org.apache.commons.text.StringEscapeUtils.escapeXml11(value);
} else {
return org.apache.commons.text.StringEscapeUtils.escapeXml10(value);
}
}

/**
* Checks and returns XML version of the envelope
*
Expand Down

0 comments on commit d60355d

Please sign in to comment.