From dbccb05c169e6b47f3f28a555d7ef4c61cf5ff29 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Sun, 27 Oct 2019 09:35:29 +0000 Subject: [PATCH] "Applied fix from trunk for revision: 1869001" ------------------------------------------------------------------------ r1869001 | mthl | 2019-10-26 16:42:02 +0200 (sam. 26 oct. 2019) | 9 lignes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed: Handle whitelist of serializable classes from properties (OFBIZ-11261) There was a bug regarding the way the ‘ListOfSafeObjectsForInputStream’ value defined in the “SafeObjectInputStream.properties” file was handled. Mistakenly only one class identifier was allowed. Some unit tests have been added to check that the identified bug is fixed. ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/branches/release17.12@1869032 13f79535-47bb-0310-9956-ffa450edef68 --- .../main/java/org/apache/ofbiz/base/util/UtilObject.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java index a1c4bfe6c6..d73aa55f2c 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilObject.java @@ -24,9 +24,11 @@ import java.io.IOException; import java.io.InputStream; import java.io.ObjectOutputStream; import java.lang.reflect.Array; +import java.util.Arrays; import java.util.Iterator; import java.util.List; import java.util.ServiceLoader; +import java.util.stream.Collectors; import org.apache.ofbiz.base.lang.Factory; import org.apache.ofbiz.base.lang.SourceMonitored; @@ -106,7 +108,10 @@ public final class UtilObject { "ListOfSafeObjectsForInputStream"); List listOfSafeObjects = null; if (UtilValidate.isNotEmpty(listOfSafeObjectsForInputStream)) { - listOfSafeObjects = java.util.Arrays.asList(listOfSafeObjectsForInputStream); + listOfSafeObjects = Arrays.stream(listOfSafeObjectsForInputStream.split(",")) + .map(String::trim) + .filter(s -> !s.isEmpty()) + .collect(Collectors.toList()); } else { listOfSafeObjects = java.util.Arrays.asList("byte\\[\\]", "foo", "SerializationInjector", "\\[Z","\\[B","\\[S","\\[I","\\[J","\\[F","\\[D","\\[C",