Skip to content

Commit 1f2eec6

Browse files
author
Srdjan Marjanovic
committed
Fix apple cloud and Outlook for mac bugs
1 parent b76ca1b commit 1f2eec6

6 files changed

Lines changed: 555 additions & 60 deletions

File tree

src/ActiveCollab/EmailReplyExtractor/Extractor/AppleCloudMailExtractor.php

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,6 @@
66

77
class AppleCloudMailExtractor extends Extractor
88
{
9-
10-
/**
11-
* Find reply separator and remove lines that are after it
12-
*
13-
* @param array $splitters
14-
* @param integer $trim_previous_lines
15-
*/
16-
protected function stripOriginalMessage(array &$splitters, $trim_previous_lines = 0)
17-
{
18-
$stripped = [];
19-
20-
foreach ($this->body as $line) {
21-
if (strpos($line, '--Boundary_') !== false) {
22-
if ($trim_previous_lines == 0) {
23-
$this->body = $stripped;
24-
} else {
25-
$this->body = array_slice($stripped, 0, count($stripped) - $trim_previous_lines);
26-
}
27-
28-
$this->stripEmptyLinesFromTheEnd();
29-
return;
30-
}
31-
$stripped[] = $line;
32-
}
33-
}
34-
359
/**
3610
* Extract Reply from Apple MAil mail
3711
*/
Lines changed: 35 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,57 @@
11
<?php
2-
namespace ActiveCollab\EmailReplyExtractor\Extractor;
32

4-
/**
5-
* @package ActiveCollab\EmailReplyExtractor\Extractor
6-
*/
7-
final class OutlookExtractor extends Extractor
8-
{
3+
namespace ActiveCollab\EmailReplyExtractor\Extractor;
4+
5+
/**
6+
*/
7+
final class OutlookExtractor extends Extractor
8+
{
99
/**
10-
* Overrides Extractor::stripSignature()
10+
* Overrides Extractor::stripSignature().
1111
*/
1212
public function stripSignature()
1313
{
14-
for ($x = 0, $lines_count = count($this->body); $x < $lines_count; $x++) {
15-
$line = trim($this->body[(($lines_count - $x) - 1)]);
16-
17-
if ($line && trim($line)) {
18-
if ($line == "-- " || $line == "--" || substr($line, 0, strlen('-- ')) == '-- ') {
19-
$this->body = array_splice($this->body, 0, (($lines_count - $x) - 1));
20-
return;
21-
}
22-
23-
// Should signature be longer than 8 lines?
24-
if ($x > 8) {
25-
return;
26-
}
14+
for ($x = 0, $lines_count = count($this->body); $x < $lines_count; ++$x) {
15+
$line = trim($this->body[(($lines_count - $x) - 1)]);
16+
17+
if ($line && trim($line)) {
18+
if ($line == '-- ' || $line == '--' || substr($line, 0, strlen('-- ')) == '-- ') {
19+
$this->body = array_splice($this->body, 0, (($lines_count - $x) - 1));
20+
21+
return;
22+
}
23+
24+
// Should signature be longer than 8 lines?
25+
if ($x > 8) {
26+
return;
27+
}
28+
}
2729
}
28-
}
2930
}
3031

3132
/**
32-
* Return original message splitters
33+
* Return original message splitters.
3334
*
3435
* @return array
3536
*/
3637
protected function getOriginalMessageSplitters()
3738
{
38-
return array_merge(parent::getOriginalMessageSplitters(), [
39-
'/\-------------------------/is',
40-
]);
39+
return array_merge(parent::getOriginalMessageSplitters(), [
40+
'/\-------------------------/is',
41+
]);
4142
}
4243

4344
/**
44-
* Strip default Outlook for Mac signature
45-
* @param string $html
45+
* Strip default Outlook for Mac signature.
46+
*
47+
* @param string $html
48+
*
4649
* @return string
4750
*/
48-
static function toPlainText($html)
51+
public static function toPlainText($html)
4952
{
50-
$html = preg_replace('/<div id="MAC_OUTLOOK_SIGNATURE".+<\/div>/','', $html);
51-
return parent::toPlainText($html);
52-
}
53+
$html = preg_replace('/<div id="MAC_OUTLOOK_SIGNATURE".+<\/div>/', '', $html);
5354

54-
}
55+
return parent::toPlainText($html);
56+
}
57+
}
Lines changed: 215 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
Return-Path: <ExampleExample@me.com>
2+
Delivered-To: example@example.com
3+
Received: from localhost (localhost [127.0.0.1])
4+
by example.com (Postfix) with ESMTP id 8D1B51A170;
5+
Mon, 28 Mar 2016 05:17:52 -0400 (EDT)
6+
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple;
7+
d=mail.manageprojects.com; s=default; t=1459156672;
8+
bh=mM0RBDEv4NuJB6lnCyFZSANICDIiV8WEb+8BwqFjHX4=;
9+
h=Subject:From:In-reply-to:Date:Cc:References:To;
10+
b=auVz5z41cj8DzlBjDVEtbtSMJ3Bcx/ER+tIOgvARhgc6EPZGUPE9/wg7pIDJayyKf
11+
+9zDUy9hHcOdYJy07ctBnaLJaG+EyJf+ADoS0LXm8jJraGYdFrmMSmdYWrufDpWPGf
12+
caQzMbHdVeeE5KECi/PfFenSxpPX7q9dKOyn7unE=
13+
Received: from example.com ([127.0.0.1])
14+
by localhost (mail.example.com [127.0.0.1]) (amavisd-new, port 10024)
15+
with ESMTP id lGlfJBe_mriv; Mon, 28 Mar 2016 05:17:52 -0400 (EDT)
16+
Received: from st11p06im-asmtp002.me.com (st11p06im-asmtp002.me.com [17.172.125.150])
17+
by example.com (Postfix) with ESMTPS id 1D7BF1A16A;
18+
Mon, 28 Mar 2016 05:17:52 -0400 (EDT)
19+
Received: from [192.168.2.143]
20+
(cable-89-216-122-78.static.sbb.rs [89.216.122.78])
21+
by st11p06im-asmtp002.me.com
22+
(Oracle Communications Messaging Server 7.0.5.36.0 64bit (built Sep 8 2015))
23+
with ESMTPSA id <0O4Q00H18SHP4F20@st11p06im-asmtp002.me.com>; Mon,
24+
28 Mar 2016 09:17:51 +0000 (GMT)
25+
X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,,
26+
definitions=2016-03-28_08:,, signatures=0
27+
X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0
28+
clxscore=1015 suspectscore=83 malwarescore=0 phishscore=0 adultscore=0
29+
bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1
30+
engine=8.0.1-1510270003 definitions=main-1603280145
31+
Content-type: multipart/alternative;
32+
boundary="Apple-Mail=_AF84C331-E242-41D9-BDEA-2DD1B980D128"
33+
MIME-version: 1.0 (Mac OS X Mail 9.3 \(3124\))
34+
Subject: Re: Test 123
35+
From: Example Example <ExampleExample@me.com>
36+
In-reply-to: <5cf43230683183b34b8639873ccf268a@activecollab>
37+
Date: Mon, 28 Mar 2016 11:17:49 +0200
38+
Cc: example@example.com
39+
Message-id: <111F9E7D-077C-43B7-AC29-AEBBB4581C54@me.com>
40+
References: <5cf43230683183b34b8639873ccf268a@activecollab>
41+
To: example@example.com
42+
43+
44+
--Apple-Mail=_AF84C331-E242-41D9-BDEA-2DD1B980D128
45+
Content-Transfer-Encoding: quoted-printable
46+
Content-Type: text/plain;
47+
charset=us-ascii
48+
49+
Evo ga.
50+
> On Mar 27, 2016, at 18:06, owner (Active Collab) =
51+
<example@example.com> wrote:
52+
>=20
53+
> - Reply above this line to leave a comment -
54+
>=20
55+
> New comment posted in:
56+
> Test 123
57+
>=20
58+
> <http://localhost/projects/1/tasks/16>
59+
> owner Mar 27. 2016=20
60+
> ccuj me
61+
> =20
62+
> Older comments
63+
> ExampleExample Mar 27. 2016=20
64+
> Ovo je reply na notifikaciju. Email #3.
65+
>=20
66+
>=20
67+
>=20
68+
>=20
69+
>=20
70+
> ExampleExample Mar 27. 2016=20
71+
> Ovo je reply na email #3. Email #4.
72+
>=20
73+
>=20
74+
>=20
75+
>=20
76+
> On Mar 28, 2016, at 11:13, Example Example wrote:
77+
>=20
78+
>=20
79+
> Ovo je reply na notifikaciju. Email #3.
80+
>=20
81+
>=20
82+
>=20
83+
> owner Mar 27. 2016=20
84+
> test
85+
> =20
86+
> Project: test project
87+
> Task List: Inbox
88+
> People in this task: ExampleExample <mailto:ExampleExample@me.com> and owner =
89+
<mailto:owner@example.com>
90+
> Delivered by ActiveCollab
91+
> Don't send me emails about this task any more =
92+
<http://feather.dev/public/notifications/unsubscribe?code=3DSUBS-27-h7zlXk=
93+
m3UD>
94+
95+
--Apple-Mail=_AF84C331-E242-41D9-BDEA-2DD1B980D128
96+
Content-Transfer-Encoding: quoted-printable
97+
Content-Type: text/html;
98+
charset=us-ascii
99+
100+
<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html =
101+
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
102+
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" =
103+
class=3D"">Evo ga.<br class=3D""><div><blockquote type=3D"cite" =
104+
class=3D""><div class=3D"">On Mar 27, 2016, at 18:06, owner (Active =
105+
Collab) &lt;<a href=3D"mailto:example@example.com" =
106+
class=3D"">example@example.com</a>&gt; wrote:</div><br =
107+
class=3D"Apple-interchange-newline"><div class=3D""><table =
108+
cellpadding=3D"10" cellspacing=3D"0" border=3D"0" align=3D"center" =
109+
style=3D"font-family: HelveticaNeue; font-size: 13px; font-style: =
110+
normal; font-variant-caps: normal; font-weight: normal; letter-spacing: =
111+
normal; orphans: auto; text-align: start; text-indent: 0px; =
112+
text-transform: none; white-space: normal; widows: auto; word-spacing: =
113+
0px; -webkit-text-stroke-width: 0px; background-color: rgb(241, 241, =
114+
241); width: 629px;" class=3D""><tbody class=3D""><tr class=3D""><td =
115+
align=3D"center" style=3D"font-family: Helvetica, Arial, sans-serif; =
116+
font-size: 11px; color: rgb(153, 153, 153);" class=3D""><p =
117+
style=3D"margin: 0px 0px 1em;" class=3D"">- Reply above this line to =
118+
leave a comment -</p><table class=3D"content" cellpadding=3D"20" =
119+
cellspacing=3D"0" align=3D"center" style=3D"width: 600px !important; =
120+
max-width: 600px; background-color: rgb(255, 255, 255); border-width: =
121+
1px; border-color: rgb(209, 209, 209); border-top-left-radius: 3px; =
122+
border-top-right-radius: 3px; border-bottom-right-radius: 3px; =
123+
border-bottom-left-radius: 3px;"><tbody class=3D""><tr class=3D""><td =
124+
align=3D"left" style=3D"font-family: Helvetica, Arial, sans-serif; =
125+
font-size: 16px; line-height: 22px; padding-top: 0px;" class=3D""><h1 =
126+
style=3D"margin: 20px 0px 16px; font-size: 16px; font-weight: bold;" =
127+
class=3D"">New comment posted in:<br class=3D""><a =
128+
href=3D"http://localhost/projects/1/tasks/16" style=3D"color: rgb(0, 94, =
129+
176); display: block; overflow: hidden; text-overflow: ellipsis; =
130+
white-space: nowrap; max-width: 550px;" class=3D"">Test =
131+
123</a></h1><table border=3D"0" cellpadding=3D"10" cellspacing=3D"0" =
132+
bgcolor=3D"#ffffff" style=3D"width: 560px;" class=3D""><tbody =
133+
class=3D""><tr class=3D""><td valign=3D"top" style=3D"padding-left: 0px; =
134+
width: 36px;" class=3D""><img =
135+
src=3D"http://feather.dev/proxy.php?proxy=3Davatar&amp;module=3Dsystem&amp=
136+
;v=3Dcurrent&amp;b=3DDEV&amp;user_id=3D1&amp;size=3D36&amp;timestamp=3D145=
137+
9094498" width=3D"36" height=3D"36" alt=3D"owner" class=3D""></td><td =
138+
colspan=3D"2" valign=3D"top" style=3D"padding-left: 0px;" =
139+
class=3D""><strong class=3D"">owner</strong><span =
140+
class=3D"Apple-converted-space">&nbsp;</span><span style=3D"font-size: =
141+
14px; line-height: 14px;" class=3D"">&nbsp;Mar 27. 2016</span><span =
142+
class=3D"Apple-converted-space">&nbsp;</span><br class=3D""><span =
143+
style=3D"word-wrap: break-word; word-break: break-word; -webkit-hyphens: =
144+
auto;" class=3D"">ccuj me</span></td></tr><tr class=3D""><td colspan=3D"2"=
145+
height=3D"1" bgcolor=3D"#cccccc" style=3D"height: 1px; font-size: 0px; =
146+
line-height: 0; padding: 0px;" class=3D"">&nbsp;</td></tr><tr =
147+
class=3D""><td valign=3D"top" style=3D"padding-bottom: 0px;" =
148+
class=3D"">&nbsp;</td><td valign=3D"top" style=3D"padding-left: 0px; =
149+
padding-bottom: 0px; padding-top: 14px; font-size: 14px; line-height: =
150+
14px; font-weight: bold;" class=3D"">Older comments</td></tr><tr =
151+
class=3D""><td valign=3D"top" style=3D"padding-left: 0px; width: 36px;" =
152+
class=3D""><img =
153+
src=3D"http://feather.dev/proxy.php?proxy=3Davatar&amp;module=3Dsystem&amp=
154+
;v=3Dcurrent&amp;b=3DDEV&amp;user_id=3D9&amp;size=3D36&amp;timestamp=3D145=
155+
9094324" width=3D"36" height=3D"36" alt=3D"ExampleExample" class=3D""></td><td =
156+
colspan=3D"2" valign=3D"top" style=3D"padding-left: 0px; color: rgb(153, =
157+
153, 153);" class=3D""><strong class=3D"">ExampleExample</strong><span =
158+
class=3D"Apple-converted-space">&nbsp;</span><span style=3D"font-size: =
159+
14px; line-height: 14px;" class=3D"">&nbsp;Mar 27. 2016</span><span =
160+
class=3D"Apple-converted-space">&nbsp;</span><br class=3D""><span =
161+
style=3D"word-wrap: break-word; word-break: break-word; -webkit-hyphens: =
162+
auto;" class=3D"">Ovo je reply na notifikaciju. Email #3.<br =
163+
class=3D""><br class=3D""><blockquote class=3D""><br class=3D""><br =
164+
class=3D""><br class=3D""><br class=3D""></blockquote></span></td></tr><tr=
165+
class=3D""><td valign=3D"top" style=3D"padding-left: 0px; width: 36px;" =
166+
class=3D""><img =
167+
src=3D"http://feather.dev/proxy.php?proxy=3Davatar&amp;module=3Dsystem&amp=
168+
;v=3Dcurrent&amp;b=3DDEV&amp;user_id=3D9&amp;size=3D36&amp;timestamp=3D145=
169+
9094324" width=3D"36" height=3D"36" alt=3D"ExampleExample" class=3D""></td><td =
170+
colspan=3D"2" valign=3D"top" style=3D"padding-left: 0px; color: rgb(153, =
171+
153, 153);" class=3D""><strong class=3D"">ExampleExample</strong><span =
172+
class=3D"Apple-converted-space">&nbsp;</span><span style=3D"font-size: =
173+
14px; line-height: 14px;" class=3D"">&nbsp;Mar 27. 2016</span><span =
174+
class=3D"Apple-converted-space">&nbsp;</span><br class=3D""><span =
175+
style=3D"word-wrap: break-word; word-break: break-word; -webkit-hyphens: =
176+
auto;" class=3D"">Ovo je reply na email #3. Email #4.<br class=3D""><br =
177+
class=3D""><blockquote class=3D""><br class=3D""><br class=3D""><br =
178+
class=3D"">On Mar 28, 2016, at 11:13, Example Example wrote:<br class=3D""><br =
179+
class=3D""><br class=3D"">Ovo je reply na notifikaciju. Email #3.<br =
180+
class=3D""><br class=3D""><br class=3D""><br =
181+
class=3D""></blockquote></span></td></tr><tr class=3D""><td valign=3D"top"=
182+
style=3D"padding-left: 0px; width: 36px;" class=3D""><img =
183+
src=3D"http://feather.dev/proxy.php?proxy=3Davatar&amp;module=3Dsystem&amp=
184+
;v=3Dcurrent&amp;b=3DDEV&amp;user_id=3D1&amp;size=3D36&amp;timestamp=3D145=
185+
9094498" width=3D"36" height=3D"36" alt=3D"owner" class=3D""></td><td =
186+
colspan=3D"2" valign=3D"top" style=3D"padding-left: 0px; color: rgb(153, =
187+
153, 153);" class=3D""><strong class=3D"">owner</strong><span =
188+
class=3D"Apple-converted-space">&nbsp;</span><span style=3D"font-size: =
189+
14px; line-height: 14px;" class=3D"">&nbsp;Mar 27. 2016</span><span =
190+
class=3D"Apple-converted-space">&nbsp;</span><br class=3D""><span =
191+
style=3D"word-wrap: break-word; word-break: break-word; -webkit-hyphens: =
192+
auto;" class=3D"">test</span></td></tr><tr class=3D""><td colspan=3D"2" =
193+
height=3D"1" bgcolor=3D"#cccccc" style=3D"height: 1px; font-size: 0px; =
194+
line-height: 0; padding: 0px;" =
195+
class=3D"">&nbsp;</td></tr></tbody></table><div class=3D"metadata" =
196+
style=3D"color: rgb(153, 153, 153); font-size: 14px; line-height: =
197+
21px;"><p style=3D"margin: 1em 0px;" class=3D"">Project: test project<br =
198+
class=3D"">Task List: Inbox<br class=3D"">People in this task:<span =
199+
class=3D"Apple-converted-space">&nbsp;</span><a =
200+
href=3D"mailto:ExampleExample@me.com" style=3D"color: rgb(153, 153, 153); =
201+
text-decoration: none;" class=3D"">ExampleExample</a><span =
202+
class=3D"Apple-converted-space">&nbsp;</span>and<span =
203+
class=3D"Apple-converted-space">&nbsp;</span><a =
204+
href=3D"mailto:owner@example.com" style=3D"color: rgb(153, 153, =
205+
153); text-decoration: none;" =
206+
class=3D"">owner</a></p></div></td></tr></tbody></table><p =
207+
style=3D"margin: 1em 0px;" class=3D"">Delivered by ActiveCollab<br =
208+
class=3D""><a =
209+
href=3D"http://feather.dev/public/notifications/unsubscribe?code=3DSUBS-27=
210+
-h7zlXkm3UD" style=3D"color: rgb(153, 153, 153);" class=3D"">Don't send =
211+
me emails about this task any =
212+
more</a></p></td></tr></tbody></table></div></blockquote></div><br =
213+
class=3D""></body></html>=
214+
215+
--Apple-Mail=_AF84C331-E242-41D9-BDEA-2DD1B980D128--

0 commit comments

Comments
 (0)