Skip to content

Commit 7e7f10c

Browse files
committed
comments, add routine to manage mime types
1 parent baf728e commit 7e7f10c

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

decode/MailParser.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,9 @@ private function extractHeadersAndBody()
195195
$this->rawBodyLines = \array_slice($lines, $i);
196196
break;
197197
}
198-
199-
// start of new header
198+
// check is line starting With printable character
200199
if (\preg_match('/^[A-Za-z]/', $line)) {
200+
// start of new header
201201
\preg_match('/([^:]+): ?(.*)$/', $line, $matches);
202202
$newHeader = \strtolower($matches[1]);
203203
$value = $matches[2];
@@ -240,6 +240,19 @@ public function addMimeType($mime_types = '')
240240
return $this;
241241
}
242242

243+
/**
244+
* Add additional disallowed mime types to the list.
245+
*
246+
* @param string
247+
*/
248+
public function removeMimeType($mime_types = '')
249+
{
250+
if (\strpos($mime_types, '/') !== false)
251+
\array_push($this->disallowedMimeTypes, $mime_types);
252+
253+
return $this;
254+
}
255+
243256
/**
244257
* @return string - UTF8 encoded
245258
*

tests/MailParserTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ public function testPlainBody()
8383

8484
$file = __DIR__ . '/emails/m0002';
8585
$email = new MailParser(\file_get_contents($file));
86+
$email->removeMimeType('audio/caf');
8687
$expect = '
8788
Hello,
8889

0 commit comments

Comments
 (0)