Skip to content
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

Invalid value separator #418

Open
dominikfiala opened this issue Mar 19, 2024 · 0 comments · May be fixed by #419
Open

Invalid value separator #418

dominikfiala opened this issue Mar 19, 2024 · 0 comments · May be fixed by #419

Comments

@dominikfiala
Copy link

Invalid characters used as a value separator instead of a standard comma are ignored by both validator and schedule.

Consider this obviously invalid CRON expression (see crontab.guru):

1;2;3 * * * *

Validation passes (which is wrong), plus the scheduler represents it as "every first minute of every hour", instead of "every first, second and third minute of every hour".

I investigated and the problem is in normalizeIntegers() that utilizes native JS function parseInt()
(see below), which behaves in unexpected ways.

numbers[j] = parseInt(numbers[j]);

If it is supplied with beforementioned string "1;2;3", it evaluates to 1.

I prepared a fix and added tests for this behavior in a fork, will make a pull request.

My suggestion is to validate the pattern string agains characters available in a CRON syntax. My implementation allows for alphanumeric chars, dash, asterisk, forward slash, comma and space.

The suggested regex is /^[a-zA-Z0-9-*/, ]+$/. It may not be perfect, but it passes all the tests already included in the codebase.

@dominikfiala dominikfiala linked a pull request Mar 19, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant