summaryrefslogtreecommitdiffstats
path: root/system/libraries/Typography.php
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-10-27 17:29:19 +0100
committerDerek Jones <derek.jones@ellislab.com>2008-10-27 17:29:19 +0100
commitc349c51427cd22fe60c2574dda233a300f5698a9 (patch)
tree8fa7def3d3d4cfdc0667101f13598c404337252d /system/libraries/Typography.php
parent0efc4d331fa1e8212c0aa01bf9c220810d14f61c (diff)
Fixed the regex matching that checks for user-submitted paragraph tags, it was incorrectly matching in cases like
<p></p><blockquote><p> resulting in a removal of the paragraph tag from within the blockquote. also tweaked some looping code to make it a hair more efficient
Diffstat (limited to 'system/libraries/Typography.php')
-rw-r--r--system/libraries/Typography.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/system/libraries/Typography.php b/system/libraries/Typography.php
index 5a97da715..9490c7ce5 100644
--- a/system/libraries/Typography.php
+++ b/system/libraries/Typography.php
@@ -86,22 +86,22 @@ class CI_Typography {
// within tags so we'll temporarily convert them to {@DQ} and {@SQ}
if (preg_match_all("#\<.+?>#si", $str, $matches))
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
{
- $str = str_replace($matches['0'][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
+ $str = str_replace($matches[0][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches[0][$i]),
$str);
}
}
-
+
if ($this->protect_braced_quotes === TRUE)
{
if (preg_match_all("#\{.+?}#si", $str, $matches))
{
- for ($i = 0; $i < count($matches['0']); $i++)
+ for ($i = 0, $total = count($matches[0]); $i < $total; $i++)
{
- $str = str_replace($matches['0'][$i],
- str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches['0'][$i]),
+ $str = str_replace($matches[0][$i],
+ str_replace(array("'",'"'), array('{@SQ}', '{@DQ}'), $matches[0][$i]),
$str);
}
}
@@ -160,13 +160,13 @@ class CI_Typography {
// Convert quotes, elipsis, and em-dashes
$str = $this->format_characters($str);
-
+
// Final clean up
$table = array(
// If the user submitted their own paragraph tags within the text
// we will retain them instead of using our tags.
- '/(<p.*?>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
+ '/(<p[^>*?]>)<p>/' => '$1', // <?php BBEdit syntax coloring bug fix
// Reduce multiple instances of opening/closing paragraph tags to a single one
'#(</p>)+#' => '</p>',