Check for asterisk range in CronExpression

This commit makes sure that in CronExpression, the asterisk is only used
in a range field, and is not surrounded by unexpected characters.

Closes gh-19500
This commit is contained in:
Arjen Poutsma 2020-08-04 16:05:47 +02:00
parent 3dc4f43852
commit 762cf0ffe8
2 changed files with 4 additions and 1 deletions

View File

@ -150,7 +150,7 @@ final class BitsCronField extends CronField {
}
private static ValueRange parseRange(String value, Type type) {
if (value.indexOf('*') != -1) {
if (value.equals("*")) {
return type.range();
}
else {

View File

@ -48,6 +48,9 @@ public class BitsCronFieldTests {
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseMonth("13"));
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseDaysOfWeek("8"));
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseSeconds("20-10"));
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseDaysOfWeek("*SUN"));
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseDaysOfWeek("SUN*"));
assertThatIllegalArgumentException().isThrownBy(() -> BitsCronField.parseHours("*ANYTHING_HERE"));
}
@Test