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 “hours” in range cause cron #next_time loop breaker issue #30

Closed
ticky opened this issue Aug 13, 2019 · 4 comments
Closed
Assignees

Comments

@ticky
Copy link

ticky commented Aug 13, 2019

Issue description

Values outside 0-23 in an hour range cause an infinite loop error.

How to reproduce

require 'fugit'
c = Fugit.parse('* 0-24 * * *')
RuntimeError (too many loops for {:min=>0, :max=>23, :sta=>0, :edn=>24, :sla=>1} #range, breaking, please fill an issue at https://git.io/fjJC9)

Expected behaviour

The “24” being out of range should either result in a parsing error or being treated as 0.

Context

Please replace the content of this section with the output of the following commands:

Darwin Kinzie 18.7.0 Darwin Kernel Version 18.7.0: Thu Jun 20 18:42:21 PDT 2019; root:xnu-4903.270.47~4/RELEASE_X86_64 x86_64
ruby 2.6.2p47 (2019-03-13 revision 67232) [x86_64-darwin18]
(secs:1565722428.8614998,utc~:"2019-08-13 18:53:48.8614997863769531",ltz~:"PDT")
(etz:nil,tnz:"PDT",tziv:"1.2.5",tzidv:nil,rv:"2.6.2",rp:"x86_64-darwin18",win:false,rorv:nil,astz:nil,eov:"1.2.1",eotnz:#<TZInfo::TimezoneProxy: America/Dawson>,eotnfz:"-0700",eotlzn:"America/Dawson",eotnfZ:"PDT",debian:nil,centos:nil,osx:"zoneinfo/America/Vancouver")

Additional context

Encountered via in-the-wild user input!

@jmettraux jmettraux self-assigned this Aug 13, 2019
@jmettraux
Copy link
Member

jmettraux commented Aug 13, 2019

https://crontab.guru/#*_0-24___* says 24 is not in the allowed values.

man 5 crontab says:

           field         allowed values
           -----         --------------
           minute        0-59
           hour          0-23
           day of month  1-31
           month         1-12 (or names, see below)
           day of week   0-7 (0 or 7 is Sun, or use names)

I should probably simply reject. But accepting 24, is lenient, à la Postel.

@jmettraux
Copy link
Member

Already accepting 24 on its own,

[ '00 24 * * *', '2017-01-02', '2017-01-01 12:00' ],
so have to be lenient.

jmettraux added a commit that referenced this issue Aug 14, 2019
@jmettraux
Copy link
Member

Released as part of fugit 1.3.2.

https://rubygems.org/gems/fugit/versions/1.3.2

Please tell me if there is anything wrong.

Many thanks with this issue report.

@ticky
Copy link
Author

ticky commented Aug 14, 2019

Thanks for the quick fix! Looking good 😄

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

No branches or pull requests

2 participants