Recognizing mime boundary according to RFC

This commit is contained in:
milamimr 2017-08-23 15:30:36 +02:00
parent 6e117940a3
commit d68c25daad
2 changed files with 3 additions and 1 deletions

View File

@ -27,7 +27,7 @@ class MimeBoundaryAnalyser
*/
public static function isMessageLineBoundary($mimeMessageLine)
{
return strlen($mimeMessageLine) > 0 && $mimeMessageLine[0] === "-";
return preg_match('/^--[0-9A-Za-z\s\'\/\+\_\,\-\.\:\=\?]+/', $mimeMessageLine) === 1;
}
/**

View File

@ -67,6 +67,8 @@ class MimeBoundaryAnalyserTest extends PHPUnit_Framework_TestCase
{
return [
['-- this line is boundary', self::EXPECTED_IS_BOUNDARY],
['--this line is boundary', self::EXPECTED_IS_BOUNDARY],
['--@ this line is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],
['-- this line is also a boundary --', self::EXPECTED_IS_BOUNDARY],
['mesage line -- is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],
[' -- mesage line -- is not boundary', self::EXPECTED_IS_NOT_BOUNDARY],