Author: jleroux
Date: Mon Nov 27 15:19:47 2017 New Revision: 1816461 URL: http://svn.apache.org/viewvc?rev=1816461&view=rev Log: Fixed: Replace org.apache.commons.lang.StringEscapeUtils.unescapeHtml() method by org.jsoup.parser.Parser.unescapeEntities() (OFBIZ-10023) StringEscapeUtils.unescapeHtml() is deprecated or at least not reliable After few tests using the Parser.unescapeEntities() strict mode seems OK Modified: ofbiz/ofbiz-framework/trunk/build.gradle ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/WidgetWorker.java Modified: ofbiz/ofbiz-framework/trunk/build.gradle URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/build.gradle?rev=1816461&r1=1816460&r2=1816461&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/build.gradle (original) +++ ofbiz/ofbiz-framework/trunk/build.gradle Mon Nov 27 15:19:47 2017 @@ -142,6 +142,7 @@ dependencies { compile 'oro:oro:2.0.8' compile 'wsdl4j:wsdl4j:1.6.3' compile 'io.jsonwebtoken:jjwt:0.9.0' + compile 'org.jsoup:jsoup:1.11.2' // ofbiz unit-test compile libs testCompile 'org.mockito:mockito-core:2.+' Modified: ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java?rev=1816461&r1=1816460&r2=1816461&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/webtools/src/main/java/org/apache/ofbiz/webtools/labelmanager/SaveLabelsToXmlFile.java Mon Nov 27 15:19:47 2017 @@ -25,7 +25,6 @@ import java.util.Locale; import java.util.Map; import java.util.Set; -import org.apache.commons.lang.StringEscapeUtils; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.FileUtil; import org.apache.ofbiz.base.util.UtilGenerics; @@ -36,6 +35,7 @@ import org.apache.ofbiz.base.util.UtilXm import org.apache.ofbiz.base.util.cache.UtilCache; import org.apache.ofbiz.service.DispatchContext; import org.apache.ofbiz.service.ServiceUtil; +import org.jsoup.parser.Parser; import org.w3c.dom.Comment; import org.w3c.dom.Document; import org.w3c.dom.Element; @@ -118,9 +118,9 @@ public class SaveLabelsToXmlFile { continue; } Element propertyElem = UtilXml.addChildElement(resourceElem, "property", resourceDocument); - propertyElem.setAttribute("key", StringEscapeUtils.unescapeHtml(labelInfo.getLabelKey())); + propertyElem.setAttribute("key", Parser.unescapeEntities(labelInfo.getLabelKey(), true)); if (UtilValidate.isNotEmpty(labelInfo.getLabelKeyComment())) { - Comment labelKeyComment = resourceDocument.createComment(StringEscapeUtils.unescapeHtml(labelInfo.getLabelKeyComment())); + Comment labelKeyComment = resourceDocument.createComment(Parser.unescapeEntities(labelInfo.getLabelKeyComment(), true)); Node parent = propertyElem.getParentNode(); parent.insertBefore(labelKeyComment, propertyElem); } @@ -131,11 +131,11 @@ public class SaveLabelsToXmlFile { valueString = labelValue.getLabelValue(); } if (UtilValidate.isNotEmpty(valueString)) { - valueString = StringEscapeUtils.unescapeHtml(valueString); + valueString = Parser.unescapeEntities(valueString, true); Element valueElem = UtilXml.addChildElementValue(propertyElem, "value", valueString, resourceDocument); valueElem.setAttribute("xml:lang", localeFound); if (UtilValidate.isNotEmpty(labelValue.getLabelComment())) { - Comment labelComment = resourceDocument.createComment(StringEscapeUtils.unescapeHtml(labelValue.getLabelComment())); + Comment labelComment = resourceDocument.createComment(Parser.unescapeEntities(labelValue.getLabelComment(), true)); Node parent = valueElem.getParentNode(); parent.insertBefore(labelComment, valueElem); } Modified: ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/WidgetWorker.java URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/WidgetWorker.java?rev=1816461&r1=1816460&r2=1816461&view=diff ============================================================================== --- ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/WidgetWorker.java (original) +++ ofbiz/ofbiz-framework/trunk/framework/widget/src/main/java/org/apache/ofbiz/widget/WidgetWorker.java Mon Nov 27 15:19:47 2017 @@ -27,7 +27,6 @@ import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import org.apache.commons.lang.StringEscapeUtils; import org.apache.ofbiz.base.util.Debug; import org.apache.ofbiz.base.util.UtilCodec; import org.apache.ofbiz.base.util.UtilGenerics; @@ -41,6 +40,7 @@ import org.apache.ofbiz.webapp.control.W import org.apache.ofbiz.webapp.taglib.ContentUrlTag; import org.apache.ofbiz.widget.model.ModelForm; import org.apache.ofbiz.widget.model.ModelFormField; +import org.jsoup.parser.Parser; public final class WidgetWorker { @@ -53,7 +53,7 @@ public final class WidgetWorker { // We may get an encoded request like: /projectmgr/control/EditTaskContents?workEffortId=10003 // Try to reducing a possibly encoded string down to its simplest form: /projectmgr/control/EditTaskContents?workEffortId=10003 // This step make sure the following appending externalLoginKey operation to work correctly - String localRequestName = StringEscapeUtils.unescapeHtml(target); + String localRequestName = Parser.unescapeEntities(target, true); localRequestName = UtilHttp.encodeAmpersands(localRequestName); Appendable localWriter = new StringWriter(); |
Free forum by Nabble | Edit this page |