Skip to content
Open
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
18 changes: 10 additions & 8 deletions lib/Service/MailFilter/FilterBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ public function buildSieveScript(array $filters, string $untouchedScript): strin
$lines[] = self::SEPARATOR;
}

/*
* Using implode("\r\n", $lines) may introduce an extra newline if the original script already ends with one.
* There may be a cleaner solution, but I couldn't find one that works seamlessly with Filter and Autoresponder.
* Feel free to give it a try!
*/
if (str_ends_with($untouchedScript, self::SIEVE_NEWLINE . self::SIEVE_NEWLINE)) {
$untouchedScript = substr($untouchedScript, 0, -2);
if (strlen($untouchedScript) !== 0) {
/*
* Using implode("\r\n", $lines) may introduce an extra newline if the original script already ends with one.
* There may be a cleaner solution, but I couldn't find one that works seamlessly with Filter and Autoresponder.
* Feel free to give it a try!
*/
if (str_ends_with($untouchedScript, self::SIEVE_NEWLINE . self::SIEVE_NEWLINE)) {
$untouchedScript = substr($untouchedScript, 0, -2);
}
$lines[] = $untouchedScript;
}
$lines[] = $untouchedScript;

if (count($filters) > 0) {
$lines[] = self::SEPARATOR;
Expand Down
Loading