Skip to content

Commit

Permalink
Merge pull request #33 from likeuntomurphy/master
Browse files Browse the repository at this point in the history
Make quote header regexes lazy to avoid collapsing multiple headers i…
  • Loading branch information
willdurand committed May 9, 2015
2 parents fe0eeb7 + e87a07a commit fd0dde0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/EmailReplyParser/Parser/EmailParser.php
Expand Up @@ -26,11 +26,11 @@ class EmailParser
* @var string[]
*/
private $quoteHeadersRegex = array(
'/^(On\s.+wrote:)$/ms', // On DATE, NAME <EMAIL> wrote:
'/^(Le\s.+écrit :)$/ms', // Le DATE, NAME <EMAIL> a écrit :
'/^(El\s.+escribió:)$/ms', // El DATE, NAME <EMAIL> escribió:
'/^(W dniu\s.+(pisze|napisał):)$/ms', // W dniu DATE, NAME <EMAIL> pisze|napisał:
'/^(20[0-9]{2}\-(?:0?[1-9]|1[012])\-(?:0?[0-9]|[1-2][0-9]|3[01]|[1-9])\s[0-2]?[0-9]:\d{2}\s.+:)$/ms', // 20YY-MM-DD HH:II GMT+01:00 NAME <EMAIL>:
'/^(On\s.+?wrote:)$/ms', // On DATE, NAME <EMAIL> wrote:
'/^(Le\s.+?écrit :)$/ms', // Le DATE, NAME <EMAIL> a écrit :
'/^(El\s.+?escribió:)$/ms', // El DATE, NAME <EMAIL> escribió:
'/^(W dniu\s.+?(pisze|napisał):)$/ms', // W dniu DATE, NAME <EMAIL> pisze|napisał:
'/^(20[0-9]{2}\-(?:0?[1-9]|1[012])\-(?:0?[0-9]|[1-2][0-9]|3[01]|[1-9])\s[0-2]?[0-9]:\d{2}\s.+?:)$/ms', // 20YY-MM-DD HH:II GMT+01:00 NAME <EMAIL>:
);

/**
Expand Down
29 changes: 29 additions & 0 deletions tests/EmailReplyParser/Tests/EmailReplyParserTest.php
Expand Up @@ -112,4 +112,33 @@ public function testUnquotedReply()

$this->assertEquals('This is my reply.', EmailReplyParser::parseReply($body));
}

public function testEmailThreadPreservesNewLines()
{
$body = $this->getFixtures('email_thread.txt');

$fragments = EmailReplyParser::read($body)
->getFragments();

$this->assertEquals(<<<EMAIL
On Nov 21, 2014, at 10:18, John Doe <john@doe123.com> wrote:
> Ok. Thanks.
>
> On Nov 21, 2014, at 9:26, Jim Beam <jim@beam123.com> wrote:
>
>>> On Nov 20, 2014, at 11:03 AM, John Doe <john@doe123.com> wrote:
>>>
>>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane?
>>> When I type last character, it is not shown anymore.
>>
>> We think we’ve tracked down the cause of this issue, write back if you see the issue after the next update. (Which will be out shortly.)
>>
>> --
>> Jim Beam – Acme Corp
>>
>
EMAIL
, (string) $fragments[1]);
}
}
21 changes: 21 additions & 0 deletions tests/Fixtures/email_thread.txt
@@ -0,0 +1,21 @@
This is new email reply in thread from bellow.

On Nov 21, 2014,
at 10:18,
John Doe <john@doe123.com> wrote:

> Ok. Thanks.
>
> On Nov 21, 2014, at 9:26, Jim Beam <jim@beam123.com> wrote:
>
>>> On Nov 20, 2014, at 11:03 AM, John Doe <john@doe123.com> wrote:
>>>
>>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane?
>>> When I type last character, it is not shown anymore.
>>
>> We think we’ve tracked down the cause of this issue, write back if you see the issue after the next update. (Which will be out shortly.)
>>
>> --
>> Jim Beam – Acme Corp
>>
>

0 comments on commit fd0dde0

Please sign in to comment.