stateless-systems / net-ftp-list

29 stars 14 forks source link

The Unix parser raises an ArgumentError: argument out of range exception for some entries #11

Open taylorskalyo opened 9 years ago

taylorskalyo commented 9 years ago

I encountered the following error while attempting to parse an FTP list entry.

Net::FTP::List.parse("-rw-r--r--   1 tig tig 39757835 Jan 26  2014 PSA 23 99 May-2010.pdf")
ArgumentError: argument out of range
        from /Users/t/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/time.rb:184:in `local'
        from /Users/t/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/time.rb:184:in `make_time'
        from /Users/t/.rvm/rubies/ruby-1.8.7-p374/lib/ruby/1.8/time.rb:243:in `parse'
        from /Users/t/code/vendor/plugins/net-ftp-list/lib/net/ftp/list/unix.rb:56:in `parse'
        from /Users/t/code/vendor/plugins/net-ftp-list/lib/net/ftp/list.rb:26:in `parse'
        from /Users/t/code/vendor/plugins/net-ftp-list/lib/net/ftp/list/parser.rb:9:in `each'
        from /Users/t/code/vendor/plugins/net-ftp-list/lib/net/ftp/list/parser.rb:9:in `with_each_parser'
        from /Users/t/code/vendor/plugins/net-ftp-list/lib/net/ftp/list.rb:25:in `parse'
        from (irb):28

It looks like the Unix parser's regex pattern matched the entry's raw string, but in an unexpected way. "PSA" was classified as the mtime_month_and_day. When this value was passed, along with the current year, to Time::parse, the exception was raised.