Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In crontab.go, we rely on https://github.com/gorhill/cronexpr to parse cron expressions, and to tell us when they're invalid. To choose what to feed into cronexpr, we pick out a number of tokens from the start of the cron line that might yield a valid cron expression, starting with the most tokens (we try 7, then 6, then 5, then 1). When we hit a valid cron expression, we stop there. Unfortunately, I overlooked the fact that cronexpr isn't exactly designed for this use case, and will not return an error when passed e.g. `@hourly foo` (it just ignores `foo` in this case). This is a problem if the user is using a shorthand cron expression and a command with 4 or more tokens: in this case, we'll attempt to parse the shorthand and the 4 first tokens in cronexpr, which will work (it'll ignore the tokens altogether), and we'll be left with a truncated command (missing the 4 first tokens). The ideal fix would be to have cronexpr reject this invalid expression for us, so I'm opening a PR there. In the meantime, I'm also opening this PR in Supercronic with a fix my fork of cronexpr.
- Loading branch information