Skip to content

Commit

Permalink
Fixed issues with regular expressions.
Browse files Browse the repository at this point in the history
1) Normalizing line breaks uselessly replaced `\n` with `\n`.
2) [A-z] matches the range including ``^`[]_\``; corrected to `a-z` and
   updated to include full RFC3986-compliant syntax including `+-.`.
3) Collapsing logic uselessly replaced 1 space with 1 space.
  • Loading branch information
MikkelPaulson committed Mar 15, 2016
1 parent f0b2877 commit 355d957
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions class.phpmailer.php
Expand Up @@ -713,7 +713,7 @@ protected function edebug($str)
case 'echo':
default:
//Normalize line breaks
$str = preg_replace('/(\r\n|\r|\n)/ms', "\n", $str);
$str = preg_replace('/\r\n?/ms', "\n", $str);
echo gmdate('Y-m-d H:i:s') . "\t" . str_replace(
"\n",
"\n \t ",
Expand Down Expand Up @@ -3297,7 +3297,7 @@ public function msgHTML($message, $basedir = '', $advanced = false)
$message
);
}
} elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[A-z]+://#', $url)) {
} elseif (substr($url, 0, 4) !== 'cid:' && !preg_match('#^[a-z][a-z0-9+.-]*://#i', $url)) {
// Do not change urls for absolute images (thanks to corvuscorax)
// Do not change urls that are already inline images
$filename = basename($url);
Expand Down Expand Up @@ -3681,7 +3681,7 @@ public function DKIM_HeaderC($signHeader)
foreach ($lines as $key => $line) {
list($heading, $value) = explode(':', $line, 2);
$heading = strtolower($heading);
$value = preg_replace('/\s+/', ' ', $value); // Compress useless spaces
$value = preg_replace('/\s{2,}/', ' ', $value); // Compress useless spaces
$lines[$key] = $heading . ':' . trim($value); // Don't forget to remove WSP around the value
}
$signHeader = implode("\r\n", $lines);
Expand Down

0 comments on commit 355d957

Please sign in to comment.