mikel/mail — pull request #405 by bpot (2012-06-05 18:18:13+00:00)
Title: Fix stack overflow (RegexpError) triggered by large emails with an envelope

We are seeing exceptions of this form when trying to parse large emails (>8MB) that include an envelope header:

/home/bpot/.rvm/gems/ree-1.8.7-2012.02/gems/mail-2.4.4/lib/mail/message.rb:1917:in `match': Stack overflow in regexp matcher: /\AFrom\s((?-mix:[\001-\010\016-\177])+)(?-mix:\r\n)(.*)/m (RegexpError)
from /home/bpot/.rvm/gems/ree-1.8.7-2012.02/gems/mail-2.4.4/lib/mail/message.rb:1917:in `set_envelope_header'
from /home/bpot/.rvm/gems/ree-1.8.7-2012.02/gems/mail-2.4.4/lib/mail/message.rb:2007:in `init_with_string'
from /home/bpot/.rvm/gems/ree-1.8.7-2012.02/gems/mail-2.4.4/lib/mail/message.rb:125:in `initialize'

You can reproduce it with this script: https://gist.github.com/fabeff81c3a6780d1e23