diff options
author | Thor (atiredmachine) <thor@bandwidthbeta.com> | 2012-01-25 05:56:21 +0100 |
---|---|---|
committer | Thor (atiredmachine) <thor@bandwidthbeta.com> | 2012-01-25 05:56:21 +0100 |
commit | d68c8192bbfb7c7d535f86dea987fd64d36a69a6 (patch) | |
tree | b57e85ac37ca206767b1a63ade0279e80d22f6c2 /system/core | |
parent | 79db4cdba1a1a80634cd76ab8fc69fce7b1a7ea6 (diff) |
Now protects <code> and <textrea> tags as well.
Diffstat (limited to 'system/core')
-rwxr-xr-x | system/core/Output.php | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/system/core/Output.php b/system/core/Output.php index bb39a7f31..8ed418a69 100755 --- a/system/core/Output.php +++ b/system/core/Output.php @@ -583,15 +583,15 @@ class CI_Output { { case 'html': - // Keep track of <pre> tags as they were before processing. + // Keep track of <pre> <code> and <textarea> tags as + // they were before processing. // We'll want to return them to this state later. preg_match_all('{<pre.+</pre>}msU',$output,$pres_clean); + preg_match_all('{<code.+</code>}msU',$output,$codes_clean); + preg_match_all('{<textarea.+</textarea>}msU',$output,$textareas_clean); - // Keep track of <pre> tags as they were before processing. - // We'll want to return them to this state later. + // Minify the CSS in all the <style> tags. preg_match_all('{<style.+</style>}msU',$output,$style_clean); - - // Run <style> content through CSS minifier foreach ($style_clean[0] as $s) { $output = str_replace($s, $this->minify($s,'css'), $output); @@ -600,15 +600,17 @@ class CI_Output { // Replaces multiple spaces with a single space. $output = preg_replace('!\s{2,}!',"\n",$output); + // Removes spaces around block-level elements. $output = preg_replace('{\s*(</?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br).*>)\s*}', '$1', $output); - // Get the mangled <pre> tags... + // Replace mangled <pre> etc. tags with unprocessed ones. preg_match_all('{<pre.+</pre>}msU',$output,$pres_messed); - - // Replace mangled <pre> tags with unprocessed <pre>s + preg_match_all('{<code.+</code>}msU',$output,$codes_messed); + preg_match_all('{<textarea.+</textarea>}msU',$output,$textareas_messed); $output = str_replace($pres_messed[0],$pres_clean[0],$output); + $output = str_replace($codes_messed[0],$codes_clean[0],$output); + $output = str_replace($textareas_messed[0],$textareas_clean[0],$output); - // ... break; |