[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sup-talk] [sup-devel] sup v2 progress report



* On Sun Mar 27 22:41:59 +0200 2011, William Morgan wrote:
 
> Heliotrope, the server component, is close to ready for a version 1 release.
> You can find it at https://github.com/wmorgan/heliotrope/.

Heliotrope (Actually Time.parse()) crashes on some illegaly formatted dates:

  /usr/lib/ruby/1.9.1/time.rb:137:in `apply_offset': undefined method `<' for nil:NilClass (NoMethodError)
  	from /usr/lib/ruby/1.9.1/time.rb:197:in `make_time'
  	from /usr/lib/ruby/1.9.1/time.rb:261:in `parse'
  	from /home/ico/external/heliotrope/lib/heliotrope/message.rb:27:in `parse!'
  	from bin/heliotrope-add:108:in `<main>'

The date of the message was "Wed, 7  2005 22:55: 1  -0180".

Fixed by adding a NoMethodError catch:

diff --git a/lib/heliotrope/message.rb b/lib/heliotrope/message.rb
index 1682062..d63e411 100644
--- a/lib/heliotrope/message.rb
+++ b/lib/heliotrope/message.rb
@@ -23,7 +23,7 @@ class Message
     @from = Person.from_string decode_header(validate_field(:from, @m.header["from"]))
     @date = begin
       Time.parse(validate_field(:date, @m.header["date"])).to_i
-    rescue ArgumentError
+    rescue ArgumentError, NoMethodError
       #puts "warning: invalid date field #{@m.header['date']}"
       Time.at 0
     end


-- 
:wq
^X^Cy^K^X^C^C^C^C
_______________________________________________
sup-talk mailing list
sup-talk@rubyforge.org
http://rubyforge.org/mailman/listinfo/sup-talk