From 50427b185c5004d6c3f7e2e0f0e40458b0906f5e Mon Sep 17 00:00:00 2001 From: GDLMadushanka Date: Mon, 25 Nov 2024 09:19:34 +0530 Subject: [PATCH] Avoid escape XML when creating params This is to avoid escape XML characters when creating parames in the dataservice call mediator Ported from https://github.com/wso2-support/micro-integrator/pull/969 Fixes wso2/product-micro-integrator/issues/3784 --- .../dataservice/DataServiceCallMediator.java | 31 ------------------- 1 file changed, 31 deletions(-) diff --git a/components/mediation/mediators/dataservices-mediator/org.wso2.micro.integrator.mediator.dataservice/src/main/java/org/wso2/micro/integrator/mediator/dataservice/DataServiceCallMediator.java b/components/mediation/mediators/dataservices-mediator/org.wso2.micro.integrator.mediator.dataservice/src/main/java/org/wso2/micro/integrator/mediator/dataservice/DataServiceCallMediator.java index 9a3b609e57..401b930c32 100644 --- a/components/mediation/mediators/dataservices-mediator/org.wso2.micro.integrator.mediator.dataservice/src/main/java/org/wso2/micro/integrator/mediator/dataservice/DataServiceCallMediator.java +++ b/components/mediation/mediators/dataservices-mediator/org.wso2.micro.integrator.mediator.dataservice/src/main/java/org/wso2/micro/integrator/mediator/dataservice/DataServiceCallMediator.java @@ -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); @@ -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 *