Skip to content

Commit fd0dde0

Browse files
committed
Merge pull request #33 from likeuntomurphy/master
Make quote header regexes lazy to avoid collapsing multiple headers i…
2 parents fe0eeb7 + e87a07a commit fd0dde0

File tree

3 files changed

+55
-5
lines changed

3 files changed

+55
-5
lines changed

src/EmailReplyParser/Parser/EmailParser.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ class EmailParser
2626
* @var string[]
2727
*/
2828
private $quoteHeadersRegex = array(
29-
'/^(On\s.+wrote:)$/ms', // On DATE, NAME <EMAIL> wrote:
30-
'/^(Le\s.+écrit :)$/ms', // Le DATE, NAME <EMAIL> a écrit :
31-
'/^(El\s.+escribió:)$/ms', // El DATE, NAME <EMAIL> escribió:
32-
'/^(W dniu\s.+(pisze|napisał):)$/ms', // W dniu DATE, NAME <EMAIL> pisze|napisał:
33-
'/^(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>:
29+
'/^(On\s.+?wrote:)$/ms', // On DATE, NAME <EMAIL> wrote:
30+
'/^(Le\s.+?écrit :)$/ms', // Le DATE, NAME <EMAIL> a écrit :
31+
'/^(El\s.+?escribió:)$/ms', // El DATE, NAME <EMAIL> escribió:
32+
'/^(W dniu\s.+?(pisze|napisał):)$/ms', // W dniu DATE, NAME <EMAIL> pisze|napisał:
33+
'/^(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>:
3434
);
3535

3636
/**

tests/EmailReplyParser/Tests/EmailReplyParserTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,33 @@ public function testUnquotedReply()
112112

113113
$this->assertEquals('This is my reply.', EmailReplyParser::parseReply($body));
114114
}
115+
116+
public function testEmailThreadPreservesNewLines()
117+
{
118+
$body = $this->getFixtures('email_thread.txt');
119+
120+
$fragments = EmailReplyParser::read($body)
121+
->getFragments();
122+
123+
$this->assertEquals(<<<EMAIL
124+
On Nov 21, 2014, at 10:18, John Doe <[email protected]> wrote:
125+
126+
> Ok. Thanks.
127+
>
128+
> On Nov 21, 2014, at 9:26, Jim Beam <[email protected]> wrote:
129+
>
130+
>>> On Nov 20, 2014, at 11:03 AM, John Doe <[email protected]> wrote:
131+
>>>
132+
>>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane?
133+
>>> When I type last character, it is not shown anymore.
134+
>>
135+
>> 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.)
136+
>>
137+
>> --
138+
>> Jim Beam – Acme Corp
139+
>>
140+
>
141+
EMAIL
142+
, (string) $fragments[1]);
143+
}
115144
}

tests/Fixtures/email_thread.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
This is new email reply in thread from bellow.
2+
3+
On Nov 21, 2014,
4+
at 10:18,
5+
John Doe <[email protected]> wrote:
6+
7+
> Ok. Thanks.
8+
>
9+
> On Nov 21, 2014, at 9:26, Jim Beam <[email protected]> wrote:
10+
>
11+
>>> On Nov 20, 2014, at 11:03 AM, John Doe <[email protected]> wrote:
12+
>>>
13+
>>> if you take a look at a short video from attachment, why full-typed filename does not stay in CMD+T pane?
14+
>>> When I type last character, it is not shown anymore.
15+
>>
16+
>> 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.)
17+
>>
18+
>> --
19+
>> Jim Beam – Acme Corp
20+
>>
21+
>

0 commit comments

Comments
 (0)