Fix handling of {unwrap} tags in word_wrap() functions
* in Email library: these tags were not removed
* in text helper: simplified code
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php
index 7e15c19..1d0605d 100644
--- a/system/helpers/text_helper.php
+++ b/system/helpers/text_helper.php
@@ -430,12 +430,12 @@
// 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 @@
}
}
- // Remove the unwrap tags and return
- return str_replace(array('{unwrap}', '{/unwrap}'), '', $output);
+ return $output;
}
}