mikel / tmail

TMail is a Ruby Email Handler.
http://tmail.rubyforge.org/
Other
73 stars 36 forks source link

Fix parser to raise a TMail::SyntaxError, not a SyntaxError #1

Closed technoweenie closed 15 years ago

technoweenie commented 15 years ago

I had a problem where a SyntaxError from TMail::Address.parse that kept halting my Delayed::Job queue. I suspect this is because SyntaxError is a core ruby exception. The patch ensures that the parser raises TMail::SyntaxError.

Here's the patch, suitable for use with git am http://gist.github.com/raw/116691/6631781ad06d5f2d10bcd3c41ed0c5910be2d7cd/gistfile1.txt

Here's a small example that shows the error:

>> TMail::Address.parse "( |"
SyntaxError: unterminated comment
  from parser.y:375:in `scan'
  from parser.y:375:in `parse_in'
  from racc/parser.rb:152:in `_racc_yyparse_c'
  from racc/parser.rb:152:in `__send__'
  from racc/parser.rb:152:in `yyparse'
  from parser.y:366:in `parse'
  from parser.y:344:in `parse'
  from /Library/Ruby/Gems/1.8/gems/tmail-1.2.3.1/lib/tmail/address.rb:84:in `parse'
  from (irb):1
mikel commented 15 years ago

Thanks! Applied.