From 125e9a0f21d3bc8b49833390008ff12765875445 Mon Sep 17 00:00:00 2001 From: Synchro Date: Tue, 5 Aug 2014 09:18:02 +0200 Subject: [PATCH] Use older PCRE pattern if using a troublesome lib version, fixes #41 and #261 --- class.phpmailer.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index eed9bc5a3..d68e59cf8 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -856,12 +856,18 @@ public function getLastMessageID() public static function validateAddress($address, $patternselect = 'auto') { if (!$patternselect or $patternselect == 'auto') { - if (defined('PCRE_VERSION')) { //Check this constant so it works when extension_loaded() is disabled - if (version_compare(PCRE_VERSION, '8.0') >= 0) { + //Check this constant first so it works when extension_loaded() is disabled by safe mode + //Constant was added in PHP 5.2.4 + if (defined('PCRE_VERSION')) { + //This pattern can get stuck in a recursive loop in PCRE <= 8.0.2 + if (version_compare(PCRE_VERSION, '8.0.3') >= 0) { $patternselect = 'pcre8'; } else { $patternselect = 'pcre'; } + } elseif (function_exists('extension_loaded') and extension_loaded('pcre')) { + //Fall back to older PCRE + $patternselect = 'pcre'; } else { //Filter_var appeared in PHP 5.2.0 and does not require the PCRE extension if (version_compare(PHP_VERSION, '5.2.0') >= 0) {