From 2a8560c9c62c16a2f044f37bfd4adf152c191ee5 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 20 May 2014 10:32:35 +0200 Subject: Regex fixes * Replace wrong "wwww." with "www." * Escape dot --- system/helpers/text_helper.php | 2 +- system/libraries/Email.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index ca19ab98b..7e15c1934 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -460,7 +460,7 @@ if ( ! function_exists('word_wrap')) while (mb_strlen($line) > $charlim) { // If the over-length word is a URL we won't wrap it - if (preg_match('!\[url.+\]|://|wwww.!', $line)) + if (preg_match('!\[url.+\]|://|www\.!', $line)) { break; } diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 63b7dc31c..2595032c9 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1203,7 +1203,7 @@ class CI_Email { do { // If the over-length word is a URL we won't wrap it - if (preg_match('!\[url.+\]|://|wwww.!', $line)) + if (preg_match('!\[url.+\]|://|www\.!', $line)) { break; } -- cgit v1.2.3-24-g4f1b From 0f7eba2a0b276e7a23e442b7a9786e04622acbba Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 20 May 2014 10:32:44 +0200 Subject: Fix handling of {unwrap} tags in word_wrap() functions * in Email library: these tags were not removed * in text helper: simplified code --- system/helpers/text_helper.php | 7 +++---- system/libraries/Email.php | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) (limited to 'system') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 7e15c1934..1d0605ddc 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -430,12 +430,12 @@ if ( ! function_exists('word_wrap')) // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); - if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches)) + if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $unwrap[] = $matches[1][$i]; - $str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str); + $str = str_replace($matches[0][$i], '{{unwrapped'.$i.'}}', $str); } } @@ -491,8 +491,7 @@ if ( ! function_exists('word_wrap')) } } - // Remove the unwrap tags and return - return str_replace(array('{unwrap}', '{/unwrap}'), '', $output); + return $output; } } diff --git a/system/libraries/Email.php b/system/libraries/Email.php index 2595032c9..fc1bbe1b2 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1173,12 +1173,12 @@ class CI_Email { // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); - if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches)) + if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $unwrap[] = $matches[1][$i]; - $str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str); + $str = str_replace($matches[0][$i], '{{unwrapped'.$i.'}}', $str); } } -- cgit v1.2.3-24-g4f1b From f0ab81362bb7732ac1a4272e950c5b6cea59bb06 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Tue, 20 May 2014 10:32:53 +0200 Subject: Pick up some changes from text helper refs 6ce4746474ddf050f7f4df61b7a22b7f5854d533 --- system/libraries/Email.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'system') diff --git a/system/libraries/Email.php b/system/libraries/Email.php index fc1bbe1b2..c39a26a15 100644 --- a/system/libraries/Email.php +++ b/system/libraries/Email.php @@ -1182,7 +1182,7 @@ class CI_Email { } } - // Use PHP's native public function to do the initial wordwrap. + // Use PHP's native function to do the initial wordwrap. // We set the cut flag to FALSE so that any individual words that are // too long get left alone. In the next step we'll deal with them. $str = wordwrap($str, $charlim, "\n", FALSE); @@ -1193,7 +1193,7 @@ class CI_Email { { // Is the line within the allowed character count? // If so we'll join it to the output and continue - if (strlen($line) <= $charlim) + if (mb_strlen($line) <= $charlim) { $output .= $line.$this->newline; continue; @@ -1209,10 +1209,10 @@ class CI_Email { } // Trim the word down - $temp .= substr($line, 0, $charlim-1); - $line = substr($line, $charlim-1); + $temp .= mb_substr($line, 0, $charlim - 1); + $line = mb_substr($line, $charlim - 1); } - while (strlen($line) > $charlim); + while (mb_strlen($line) > $charlim); // If $temp contains data it means we had to split up an over-length // word into smaller chunks so we'll add it back to our current line -- cgit v1.2.3-24-g4f1b