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

Use end instead of start #25

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

andreip
Copy link

@andreip andreip commented Jul 4, 2018

These changes don't modify the current functionality but, as mentioned in the commit message descriptions, it logically makes more sense to use end instead of start, since find_unwrap_start could return a start != end, and in those cases we'd like to start looking for headers from end+1 instead of from start+1. Furthermore, if the headers don't start at the first line, extract_headers will fail, so another argument to use end + 1.

Do you think I should add some "artificially" created tests for these updates? Like mentioned in the comments, some of them would look like:

---------- Forwarded
message ----------
From: Someone <[email protected]>
Date: Fri, Apr 26, 2013 at 8:13 PM
Subject: Weekend Spanish classes

and

On 2012-10-16 at 17:02 ,
Someone <[email protected]> wrote:

Some quoted text

notice that in both cases the header line for reply/forward takes two lines so this makes end != start as returned by find_unwrap_start, but that shouldn't really happen in real emails since those look poorly formatted and email clients would probably fix this?

Logically this makes more sense, since find_unwrap_start can
theoretically return a distinct start and end. Although in practice the
headers could appear only in "forward" scenario where start and end are
the same, so this doesn't really matter. If you'd like to artificially
build a test case where the previous code would fail, you'd put the
forward pattern on two lines:

---------- Forwarded
message ----------
From: Someone <[email protected]>
Date: Fri, Apr 26, 2013 at 8:13 PM
Subject: Weekend Spanish classes
Same as before for headers starting, this makes more sense logically, if
the previous pattern occupies two lines instead of one. One could
artifically build a scenario where the reply header takes two lines and
the quoted text doesn't have ">" in it, to reach this else branch logic:

On 2012-10-16 at 17:02 ,
Someone <[email protected]> wrote:

Some quoted text
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 this pull request may close these issues.

1 participant