X-Git-Url: http://git.onelab.eu/?p=www-register-wizard.git;a=blobdiff_plain;f=libraries%2FTypography.php;h=242ca3cb618d7f66d922227409d5e826706e13f0;hp=0ee6a24d08d35ca50a339a7637d0626d7a9e9efb;hb=47598daa8c32dbbd72db83dc33f2ce91b3f6f7b0;hpb=4afb2fe256f094a1caf6bff14f51c6a88938cc9f diff --git a/libraries/Typography.php b/libraries/Typography.php index 0ee6a24..242ca3c 100644 --- a/libraries/Typography.php +++ b/libraries/Typography.php @@ -6,7 +6,7 @@ * * @package CodeIgniter * @author ExpressionEngine Dev Team - * @copyright Copyright (c) 2008, EllisLab, Inc. + * @copyright Copyright (c) 2008 - 2009, EllisLab, Inc. * @license http://codeigniter.com/user_guide/license.html * @link http://codeigniter.com * @since Version 1.0 @@ -30,11 +30,17 @@ class CI_Typography { var $block_elements = 'address|blockquote|div|dl|fieldset|form|h\d|hr|noscript|object|ol|p|pre|script|table|ul'; // Elements that should not have

and
tags within them. - var $skip_elements = 'p|pre|ol|ul|dl|object|table'; + var $skip_elements = 'p|pre|ol|ul|dl|object|table|h\d'; // Tags we want the parser to completely ignore when splitting the string. - var $inline_elements = 'a|abbr|acronym|b|bdo|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|samp|select|span|strong|sub|sup|textarea|var'; - + var $inline_elements = 'a|abbr|acronym|b|bdo|big|br|button|cite|code|del|dfn|em|i|img|ins|input|label|map|kbd|q|samp|select|small|span|strong|sub|sup|textarea|tt|var'; + + // array of block level elements that require inner content to be within another block level element + var $inner_block_required = array('blockquote'); + + // the last block element parsed + var $last_block_element = ''; + // whether or not to protect quotes within { curly braces } var $protect_braced_quotes = FALSE; @@ -59,11 +65,10 @@ class CI_Typography { * * @access public * @param string - * @param bool whether to strip javascript event handlers for security * @param bool whether to reduce more then two consecutive newlines to two * @return string */ - function auto_typography($str, $strip_js_event_handlers = TRUE, $reduce_linebreaks = FALSE) + function auto_typography($str, $reduce_linebreaks = FALSE) { if ($str == '') { @@ -81,39 +86,38 @@ class CI_Typography { if ($reduce_linebreaks === TRUE) { $str = preg_replace("/\n\n+/", "\n\n", $str); - } - - // Do we allow JavaScript event handlers? If not, we strip them from within all tags - if ($strip_js_event_handlers === TRUE) - { - $str = preg_replace("#<([^><]+?)([^a-z_\-]on\w*|xmlns)(\s*=\s*[^><]*)([><]*)#i", "<\\1\\4", $str); - } + } - // Convert quotes within tags to temporary markers. We don't want quotes converted - // within tags so we'll temporarily convert them to {@DQ} and {@SQ} - if (preg_match_all("#\<.+?>#si", $str, $matches)) + // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed + $html_comments = array(); + if (strpos($str, '