From 0fe7b2eefcbfb9655573e341022c5561671c3e7a Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sat, 25 May 2019 13:34:47 +0000 Subject: [PATCH] "Applied fix from trunk for revision: 1859968" ------------------------------------------------------------------------ r1859968 | jleroux | 2019-05-25 15:25:34 +0200 (sam. 25 mai 2019) | 16 lignes Fixed: Services allow arbitrary HTML for parameters with allow-html set to "safe" (OFBIZ-5254) The testCreateNewRequest was failing due to escaped single quotes in related data in OrderTypeData.xml: subject="OFBiz - Your Request is received: '${custRequestName}' #CR${custRequestId}" This was a peculiar case that could be generalised to all escapable characters. The general solution is to compare the original value with the filtered value unescaped in UtilCodec::checkStringForHtmlSafe. BTW, weirdly enough StringEscapeUtils::escapeHtml4 does not escape single quote. Another weirdness is the test was passing with plugins data loaded. This is due to duplicated demo data in scrumTypeData.xml (which is actually not only type data, as ever the scrum component is a mess, that's not new and always wonder if we should not get rid of it!) ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1859970 13f79535-47bb-0310-9956-ffa450edef68 --- build.gradle | 1 + .../src/main/java/org/apache/ofbiz/base/util/UtilCodec.java | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4ace17320f..6aff45fff2 100644 --- a/build.gradle +++ b/build.gradle @@ -132,6 +132,7 @@ dependencies { compile 'org.apache.commons:commons-collections4:4.1' compile 'org.apache.commons:commons-csv:1.5' compile 'org.apache.commons:commons-dbcp2:2.1.1' + compile 'org.apache.commons:commons-text:1.6' compile 'org.apache.geronimo.components:geronimo-transaction:3.1.4' compile 'org.apache.geronimo.specs:geronimo-jms_1.1_spec:1.1.1' compile 'org.apache.httpcomponents:httpclient-cache:4.5.4' diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java index a5e662f3c2..2ded380f00 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilCodec.java @@ -34,6 +34,7 @@ import java.util.Map; import java.util.Set; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.text.StringEscapeUtils; import org.apache.ofbiz.base.html.SanitizerCustomPolicy; import org.owasp.esapi.codecs.Codec; import org.owasp.esapi.codecs.HTMLEntityCodec; @@ -456,7 +457,7 @@ public class UtilCodec { } String filtered = policy.sanitize(value); - if (!value.equals(filtered)) { + if (!value.equals(StringEscapeUtils.unescapeHtml4(filtered))) { String issueMsg = null; if (locale.equals(new Locale("test"))) { issueMsg = "In field [" + valueName + "] by our input policy, your input has not been accepted "