alpinweis / cronex

Ruby library that converts cron expressions into human readable strings
Other
78 stars 29 forks source link

Integer() changed to Utils.number to handle octal values #3

Closed babakgh closed 7 years ago

babakgh commented 7 years ago

In Integer(): the leading zero leads Ruby to think it's octal, but 8 & 9 isn't valid in an octal number. https://www.ruby-forum.com/topic/62141

So in some of following expressions, it would raise errors

# would raise exception
Integer("08") #=> ArgumentError: invalid value for Integer(): "08"
Cronex::ExpressionDescriptor.new("00 09 * * 7").description #=> ArgumentError: invalid value for Integer(): "09"

# works fine
Cronex::ExpressionDescriptor.new("00 9 * * 7").description #=>  "At 9:00 AM, only on Sunday"

I fixed the issue by creating new method Cronex::Utils.number and changed all Integer() with it

babakgh commented 7 years ago

It would be nice if you merge the changes asap. we have a complaint from a customer, thanks

alpinweis commented 7 years ago

I wonder if minutes/hours with a leading zero are valid at all. According to the crontab specs they are not. see http://crontab.org also see this thread http://unix.stackexchange.com/questions/121692/cron-midnight-00-24-or-00-00

alpinweis commented 7 years ago

fixed in c5bb5e3a6a6b4b0cfb12effc14eb2d0da2d6155d lmk otherwise

babakgh commented 7 years ago

@alpinweis , thats fine, thanks, can you please upload the binary Gem version 0.4.0