-
-
Notifications
You must be signed in to change notification settings - Fork 125
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Valid cron expression is not accepted #5
Comments
I forked this repo and added 2 more tests with all the valid/invalid expressions from my crontab-validator tests. Seems there are a couple of expressions that do not pass validation:
|
#4 Seems to be a byproduct of this. |
Thanks for this
On mobile, but I don't believe you can have ranges and lists as part of a
single cron element.
This was a break from 1.x, as 2.x tries to stick to a stock syntax provided
by default systems like cronie, as 1.x was _very_ generous in what it
accepted. There are also multiple cron syntaxes, which doesn't help.
I'll double check this when I get back to a PC.
|
You are correct on the check. We explicitly disallowed ranges and lists in the same expression. And here's where I misread part of the cronie source code: https://github.com/cronie-crond/cronie/blob/master/src/entry.c#L431
Marking this as a bug. If you have a PR that would be great, but if not looks like if we need to remove that constraint, and make sure that each split of the list expands ranges out. |
Thanks for your quick replies. I also checked the underlying standard of crontab (IEEE Std1003.2-1992) again at http://linuxreviews.org/man/crontab/. From the EXTENSIONS section:
So yes, it indeed depends on the system. The best way to solve this would be to provide the possibility of multiple validation strategies which is a bigger effort of course. What I can do:
|
Hi, I am interested in this cron parser and the possibility to use ranges and lists together. @hollodotme I see you already created a fork for this. Did you get this to run? Have you merged it to your master so it can be installed through composer? :-) |
@matzeeable I am still working on the patch for this repo. But because I needed a "quick" solution which the patch will be based on, I created https://github.com/hollodotme/crontab-expression with the following features:
In my repo the expression is not mutable at the moment, because I didn't need it. That's the main reason I did not finish the patch yet. |
* Updated to use new release of cron-expression * fix test
@hollodotme Can you check the latest master? I've made a change that should allow for lists and ranges in the same expression. Thanks! |
Closing this issue for now. We added support in master for lists and ranges in the same expression. |
Input
$expression = '2,17,35,47 5-7,11-13 * * *';
Expected behaviour
CronExpression::isValidExpression($expression)
returnstrue
CronExpression::factory($expression)
returns aCronExpression
instance.Referring to crontab.guru this is a valid expression.
Actual behaviour
CronExpression::isValidExpression($expression)
returnsfalse
CronExpression::factory($expression)
throws anInvalidArgumentException
with messageInvalid CRON field value 5-7,11-13 at position 1
Identified cause
Range and list at the same time in the same field are not accepted.
See https://github.com/dragonmantank/cron-expression/blob/v2.0.0/src/Cron/AbstractField.php#L210
I would like to provide a PR, if you confirm this is a valid issue.
I once implemented a cron expression validator myself, which allows this expression. I updated it today to be compatible with the PHPUnit 6+ version.
The text was updated successfully, but these errors were encountered: