From fff00e8efe38ef3f0e2964051459eac354935ecc Mon Sep 17 00:00:00 2001 From: Phergus <34379254+Phergus@users.noreply.github.com> Date: Fri, 19 Nov 2021 08:43:24 -0700 Subject: [PATCH 1/2] Update StringFunctions.java Trim whitespace off of strings before evaluation. --- .../net/rptools/maptool/client/functions/StringFunctions.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java b/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java index e482fc3c38..915fa2742f 100644 --- a/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java @@ -273,7 +273,7 @@ public Object childEvaluate( } } if (functionName.equalsIgnoreCase("isNumber")) { - if (NumberUtils.isParsable(parameters.get(0).toString())) { + if (NumberUtils.isParsable(parameters.get(0).toString().trim())) { return BigDecimal.ONE; } else { return BigDecimal.ZERO; From 6f1ddbd372dc3344ed165307a419ddfe830eac07 Mon Sep 17 00:00:00 2001 From: Phergus <34379254+Phergus@users.noreply.github.com> Date: Fri, 19 Nov 2021 09:30:47 -0700 Subject: [PATCH 2/2] Update StringFunctions.java Handle leading '+' character for numbers. --- .../rptools/maptool/client/functions/StringFunctions.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java b/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java index 915fa2742f..567e2019e3 100644 --- a/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/StringFunctions.java @@ -273,7 +273,13 @@ public Object childEvaluate( } } if (functionName.equalsIgnoreCase("isNumber")) { - if (NumberUtils.isParsable(parameters.get(0).toString().trim())) { + String str = parameters.get(0).toString().trim(); + // isParsable() returns false for leading + so stripping + // off the first one. Any extras will return false. + if (str.length() > 1 && str.charAt(0) == '+') { + str = str.substring(1); + } + if (NumberUtils.isParsable(str)) { return BigDecimal.ONE; } else { return BigDecimal.ZERO;