taichino / croniter

croniter is a python module to provide iteration for datetime object.
http://github.com/taichino/croniter
387 stars 105 forks source link

croniter accepts syntactically incorrect cron expressions #157

Closed cuu508 closed 3 years ago

cuu508 commented 3 years ago

I found a few cases where croniter accepts a malformed cron expression.

croniter accepts 1-1_0 * * * * and interprets it as 1-10 * * * *

When parsing range with a step, croniter uses int(), which accepts underscores for grouping digits.


croniter accepts 0-10/ * * * * and interprets it as 0-10/1 * * * *

The step_search_re allows for an empty step, and substitutes the empty step with "1"


A slightly different problem: inconsist handling of lowercase and uppercase "L".

croniter accepts * * 10-l * * but rejects * * 10-L * *.

Perhaps it should convert the expression to lowercase as an early step during the parsing.

cuu508 commented 3 years ago

PS. I'm happy to try my hand at writing a PR for fixing each of the above.

kiorky commented 3 years ago

If you can make the PR, yes a big thanks as i can't do it quickly for now, can you make them on https://github.com/kiorky/croniter ?

kiorky commented 3 years ago

https://pypi.org/project/croniter/1.0.7/ is out, do we have something more to close this bug @cuu508 ? And, again, thanks a lot !

cuu508 commented 3 years ago

I'd like to, but haven't yet made a PR for the * * 10-l * * and * * 10-L * * inconsistency.

(I wanted to do each fix in a separate PR, but didn't want to do too many at the time, to not run into merge conflicts.)

kiorky commented 3 years ago

Please proceed next then, :=)

kiorky commented 3 years ago

Everything done here, afterall ?

cuu508 commented 3 years ago

Yes – thank you for reviewing and accepting these PRs!