Multiline quote regex
Currently, there is no constraint between On and wrote: _MULTI_QUOTE_HDR_REGEX = r'(?!On.*On\s.+?wrote:)(On\s(.+?)wrote:)'.
So, even if there is a million characters between On ... blah blah blah ... wrote: it still detects as a multiline quote.
I think the gap between On and wrote: needs to be controlled.
I discovered this bug when the library took 1 minute to parse a long email with multiple On and wrote.
I'm creating a PR for this.
I can't comment on your pr, but your issue does bring up a question i've been trying to resolve. The above regex seems to only match the final 'On ,.. wrote:' in a multi reply chain. (because the lookahead prevents any 'On...On...wrote:' and also because the .*? is non-greedy). Subsequently, the code replaces any \n in the match with ''. (I notice they use 2 regexes, but since neither has an explict anchor I believe they are equivalent). In any case, this is causing errors in reply-chain parsing in the case where an non-end of chain quoted email has a newline in the quote header because those don't get fixed and thus don't get recognized as headers. It seems like it should be matching each quote header not just the final one?