From 98abd377d05530190ee954bee16768c7dc4adb59 Mon Sep 17 00:00:00 2001 From: Jacques Le Roux Date: Wed, 13 Nov 2024 05:58:03 +0100 Subject: [PATCH] Fixed: Support non-breaking spaces in numeric strings (OFBIZ-13168) Uses isAssignableFrom instead of enumeration of possible Number subclasses --- .../src/main/java/org/apache/ofbiz/base/util/ObjectType.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java index 17aa452395..2fb1e89767 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java @@ -21,7 +21,6 @@ import java.io.Serializable; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; -import java.math.BigDecimal; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -561,8 +560,7 @@ public static Object simpleTypeConvert(Object obj, String type, String format, T if (converter != null) { // numeric types : replace everything that's not in [:IsAlnum:] or [:IsPunct:] classes by an empty string - List numericClasses = UtilMisc.toList(BigDecimal.class, Double.class, Float.class, Long.class); - if (obj instanceof String && numericClasses.contains(targetClass)) { + if (obj instanceof String && Number.class.isAssignableFrom((targetClass))) { obj = ((String) obj).replaceAll("[^\\p{IsAlnum}\\p{IsPunct}]", ""); }