Skip to content

Commit 604d4e6

Browse files
ars18wrwiText-CI
authored andcommitted
Improve isVersionNumeric.
Previously the method accepted double or/and negative values. DEVSIX-3648 Autoported commit. Original commit hash: [2ac169237]
1 parent c45573f commit 604d4e6

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

itext/itext.kernel/itext/kernel/Version.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,10 @@ internal static String[] ParseVersionString(String version) {
286286
}
287287

288288
internal static bool IsVersionNumeric(String version) {
289-
//I did not want to introduce an extra dependency on apache.commons in order to use StringUtils.
290-
//This small method is not the most optimal, but it should do for release
291289
try {
292-
Double.Parse(version, System.Globalization.CultureInfo.InvariantCulture);
293-
return true;
290+
int value = (int)Convert.ToInt32(version);
291+
// parseInt accepts numbers which start with a plus sign, but for a version it's unacceptable
292+
return value >= 0 && !version.Contains("+");
294293
}
295294
catch (FormatException) {
296295
return false;

port-hash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
c4350c80a574cb144e5687475ccf6aaa90af4b1a
1+
2ac169237cc009d2bbc9d7386fe35abf79eb38e5

0 commit comments

Comments
 (0)