Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiline quote regex #43

Open
phongvis opened this issue Jun 26, 2020 · 1 comment · May be fixed by #44
Open

Multiline quote regex #43

phongvis opened this issue Jun 26, 2020 · 1 comment · May be fixed by #44

Comments

@phongvis
Copy link

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.

@phongvis phongvis linked a pull request Jun 26, 2020 that will close this issue
@laurb
Copy link

laurb commented Dec 18, 2020

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants