Skip to content
Merged
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 @@ -717,7 +717,7 @@ private static boolean isNumeric(String str) {
}

for (char c : str.toCharArray()) {
if (!Character.isDigit(c)) {
if (c < '0' || c > '9') {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

personally I prefer

c >= '0' && c <= '9'

but either way is fine

return false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,26 @@ void thrownParseOutputTimestampInstant(String outputTimestamp) {
.withCauseInstanceOf(DateTimeParseException.class);
}

@ParameterizedTest
@ValueSource(
strings = {
// Arabic-Indic digits (U+0660–U+0669)
"٠١٢٣٤٥٦٧٨٩",
// Bengali digits (U+09E6–U+09EF)
"০১২৩৪",
// Devanagari digits (U+0966–U+096F)
"०१२३४",
// Extended Arabic-Indic digits (U+06F0–U+06F9)
"۰۱۲۳۴"
})
void unicodeDigitsAreRejectedAsTimestamp(String unicodeDigits) {
// Character.isDigit() returns true for non-ASCII digits, but Long.parseLong() only accepts ASCII 0-9.
// These must not throw NumberFormatException — they must yield IAE with DateTimeParseException cause.
assertThatExceptionOfType(IllegalArgumentException.class)
.isThrownBy(() -> MavenArchiver.parseBuildOutputTimestamp(unicodeDigits))
.withCauseInstanceOf(DateTimeParseException.class);
}

@ParameterizedTest
@CsvSource({
"2011-12-03T10:15:30+01,1322903730",
Expand Down
Loading