Skip to content

Commit 14e8371

Browse files
committed
Avoid PHP Notices on non-standard mail header lines that don't contain a column, reporting warning to syslog.
1 parent 729a3e5 commit 14e8371

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 1.0.6 (UNRELEASED)
4+
5+
- Avoid PHP Notices on non-standard mail header lines that don't contain a column, reporting warning to syslog.
6+
37
## 1.0.5 (2019-10-29)
48

59
- Fix for newline after `whoami` shell output, which broke message logging to syslog.

app/StdinMailParser.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ public function getParsedHeaderArr()
108108
$headerLines = explode(PHP_EOL, $this->_header);
109109
$headerArr = [];
110110
foreach ($headerLines as $line) {
111-
list($key, $value) = explode(":", $line);
111+
list($key, $value) = @explode(":", $line);
112+
if (is_null($value)) {
113+
// avoid 'PHP Notice: Undefined offset: 1' on header line without colon
114+
syslog(LOG_WARNING, sprintf('%s: Could not parse mail header line: %s', __METHOD__, $line));
115+
}
112116
$key = strtolower(trim($key));
113117
$value = trim($value);
114118
if (isset($headerArr[$key]) && !in_array($key, $this->_rfc5322MultiHeaders)) {

0 commit comments

Comments
 (0)