Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions src/EmailReplyParser/Parser/EmailParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class EmailParser
*
* @var string
*/
private $signatureRegex = '/(?:^\s*--|^\s*__|^-\w|^-- $)|(?:^Sent from (my|Mail) (?:\s*\w+){1,4}$)|(?:^={30,}$)$/s';
private $signatureRegex = [
'/(?:^\s*--|^\s*__|^-\w|^-- $)|(?:^Sent from (my|Mail) (?:\s*\w+){1,4}$)|(?:^={30,}$)$/s',
'/(?:^\s*--|^\s*__|^-\w|^-- $)|(?:^Verstuurd vanaf mijn (?:\s*\w+){1,4}$)|(?:^={30,}$)$/s',
];

/**
* @var string[]
Expand Down Expand Up @@ -151,7 +154,7 @@ public function setQuoteHeadersRegex(array $quoteHeadersRegex)
}

/**
* @return string
* @return string[]
* @since 2.7.0
*/
public function getSignatureRegex()
Expand All @@ -160,12 +163,12 @@ public function getSignatureRegex()
}

/**
* @param string $signatureRegex
* @param string[] $signatureRegex
*
* @return EmailParser
* @since 2.7.0
*/
public function setSignatureRegex($signatureRegex)
public function setSignatureRegex(array $signatureRegex)
{
$this->signatureRegex = $signatureRegex;

Expand Down Expand Up @@ -205,7 +208,13 @@ private function isQuoteHeader($line)

private function isSignature($line)
{
return preg_match($this->signatureRegex, $line) ? true : false;
foreach ($this->signatureRegex as $regex) {
if (preg_match($regex, $line)) {
return true;
}
}

return false;
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/EmailReplyParser/Tests/Parser/EmailParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,10 @@ public function testEmailWithFairAmountOfContent()
*/
public function testCustomSignatureRegex()
{
$signatureRegex = '/(?:^\s*--|^\s*__|^-- $)|(?:^Sent from my (?:\s*\w+){1,3})$/s';
$signatureRegex = [
'/^DOESNT_MATCH_ANYTHING$/',
'/(?:^\s*--|^\s*__|^-- $)|(?:^Sent from my (?:\s*\w+){1,3})$/s',
];
$this->parser->setSignatureRegex($signatureRegex);
$email = $this->parser->parse($this->getFixtures('email_ls-l.txt'));
$fragments = $email->getFragments();
Expand Down
3 changes: 3 additions & 0 deletions tests/Fixtures/email_iphone_dutch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Hier is nog een e-mail

Verstuurd vanaf mijn iPhone