Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -331,13 +331,10 @@ public static Object simpleTypeOrObjectConvert(Object obj, String type, String f
}

if (converter != null) {
// numeric types : replace non-breaking spaces (which break parsing) by normal spaces
// numeric types : replace everything that's not in [:alumn:] or [:punct:] classes by regular spaces
List<?> numericClasses = UtilMisc.toList(BigDecimal.class, Double.class, Float.class);
if (obj instanceof String && numericClasses.contains(targetClass)) {
final String[] tmp = {String.valueOf(obj)};
List<Character> nonBreakingWhitespaces = UtilMisc.toList('\u00A0', '\u202F', '\u2007');
nonBreakingWhitespaces.forEach(character -> tmp[0] = tmp[0].replace(character, ' '));
obj = tmp[0];
obj = ((String) obj).replaceAll("[^\\p{Alnum}\\p{Punct}]", " ");
}

if (converter instanceof LocalizedConverter) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public void testArray() throws GeneralException {
}

@Test
public void testString() throws GeneralException, Exception {
public void testString() throws GeneralException {
simpleTypeOrObjectConvertTest("String->String", "one", "String", "one");
simpleTypeOrObjectConvertTest("String->String", "one", "java.lang.String", "one");
simpleTypeOrObjectConvertTestSingleMulti("empty-String->anything", "", new String[] {"List", "Map"}, null);
Expand Down