Skip to content

Commit

Permalink
Minor improvements to the Output class
Browse files Browse the repository at this point in the history
  • Loading branch information
narfbg committed Dec 28, 2012
1 parent 893215c commit a43417d
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions system/core/Output.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public function set_content_type($mime_type, $charset = NULL)
}

$header = 'Content-Type: '.$mime_type
.(empty($charset) ? NULL : '; charset='.strtolower($charset));
.(empty($charset) ? NULL : '; charset='.$charset);

$this->headers[] = array($header, TRUE);
return $this;
Expand Down Expand Up @@ -810,8 +810,7 @@ public function minify($output, $type = 'text/html')
* closing parenthesis are not recognized by the script. For best results
* be sure to terminate lines with a semicolon when appropriate.
*
*
* @param string $output Output to minify
* @param string $output Output to minify
* @param bool $has_tags Specify if the output has style or script tags
* @return string Minified output
*/
Expand Down Expand Up @@ -861,7 +860,9 @@ protected function _minify_script_style($output, $has_tags = FALSE)
// or not preceded/followed \ $ and _
if ((preg_match('/^[\x20-\x7f]*$/D', $next) OR preg_match('/^[\x20-\x7f]*$/D', $prev))
&& ( ! ctype_alnum($next) OR ! ctype_alnum($prev))
&& ( ! in_array($next, array('\\', '_', '$')) && ! in_array($prev, array('\\', '_', '$'))))
&& ! in_array($next, array('\\', '_', '$'), TRUE)
&& ! in_array($prev, array('\\', '_', '$'), TRUE)
)
{
unset($array_output[$key]);
}
Expand Down Expand Up @@ -895,13 +896,16 @@ protected function _minify_script_style($output, $has_tags = FALSE)
{
foreach ($feed_position as $position)
{
$next_char = substr($output, $position[1] - $removed_lf + 1, 1);
$prev_char = substr($output, $position[1] - $removed_lf - 1, 1);
if ( ! ctype_print($next_char) && ! ctype_print($prev_char)
&& ! preg_match('/^[\x20-\x7f]*$/D', $next_char)
&& ! preg_match('/^[\x20-\x7f]*$/D', $prev_char))
$position = $position[1] - $removed_lf;
$next = $output[$position + 1];
$prev = $output[$position - 1];
if ( ! ctype_print($next) && ! ctype_print($prev)
&& ! preg_match('/^[\x20-\x7f]*$/D', $next)
&& ! preg_match('/^[\x20-\x7f]*$/D', $prev)
)
{
$output = substr_replace($output, '', $position[1] - $removed_lf++, 1);
$output = substr_replace($output, '', $position, 1);
$removed_lf++;
}
}
}
Expand Down

0 comments on commit a43417d

Please sign in to comment.