Skip to content

Commit 2ac1692

Browse files
committed
Improve isVersionNumeric.
Previously the method accepted double or/and negative values. DEVSIX-3648
1 parent c4350c8 commit 2ac1692

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

kernel/src/main/java/com/itextpdf/kernel/Version.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,10 @@ static String[] parseVersionString(String version) {
281281
}
282282

283283
static boolean isVersionNumeric(String version) {
284-
//I did not want to introduce an extra dependency on apache.commons in order to use StringUtils.
285-
//This small method is not the most optimal, but it should do for release
286284
try {
287-
Double.parseDouble(version);
288-
return true;
285+
int value = (int) Integer.parseInt(version);
286+
// parseInt accepts numbers which start with a plus sign, but for a version it's unacceptable
287+
return value >= 0 && !version.contains("+");
289288
} catch (NumberFormatException e) {
290289
return false;
291290
}

0 commit comments

Comments
 (0)