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 41f6f8c commit 910667b
Showing 1 changed file with 1 addition and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

import java.io.Serializable;
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 @@ -332,8 +331,7 @@ public static Object simpleTypeOrObjectConvert(Object obj, String type, String f

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 910667b

Please sign in to comment.