Skip to content

Commit

Permalink
Fixed: Support non-breaking spaces in numeric strings (OFBIZ-13168)
Browse files Browse the repository at this point in the history
Uses isAssignableFrom instead of enumeration of possible Number subclasses
  • Loading branch information
JacquesLeRoux committed Nov 13, 2024
1 parent 8a3293a commit 98abd37
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}]", "");
}

Expand Down

0 comments on commit 98abd37

Please sign in to comment.