summaryrefslogtreecommitdiffstats
path: root/system
diff options
context:
space:
mode:
Diffstat (limited to 'system')
-rw-r--r--system/core/Output.php37
-rw-r--r--system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php2
-rw-r--r--system/database/drivers/postgre/postgre_driver.php2
3 files changed, 35 insertions, 6 deletions
diff --git a/system/core/Output.php b/system/core/Output.php
index 06d7a866b..7c2a64d24 100644
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -841,14 +841,43 @@ class CI_Output {
$output = substr_replace($output, '', 0, $pos);
// Remove closing tag and save it for later
- $pos = strpos($output, '</');
- $closing_tag = substr($output, $pos, strlen($output));
+ $pos = strrpos($output, '</');
+ $closing_tag = substr($output, $pos);
$output = substr_replace($output, '', $pos);
}
// Remove CSS comments
$output = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!i', '', $output);
+ // Remove Javascript inline comments
+ if ($has_tags === TRUE && strpos(strtolower($open_tag), 'script') !== FALSE)
+ {
+ $lines = preg_split('/\r?\n|\n?\r/', $output);
+ foreach ($lines as &$line)
+ {
+ $in_string = $in_dstring = FALSE;
+ for ($i = 0, $len = strlen($line); $i < $len; $i++)
+ {
+ if ( ! $in_string && ! $in_dstring && substr($line, $i, 2) === '//')
+ {
+ $line = substr($line, 0, $i);
+ break;
+ }
+
+ if ($line[$i] === "'" && ! $in_dstring)
+ {
+ $in_string = ! $in_string;
+ }
+ elseif ($line[$i] === '"' && ! $in_string)
+ {
+ $in_dstring = ! $in_dstring;
+ }
+ }
+ }
+
+ $output = implode("\n", $lines);
+ }
+
// Remove spaces around curly brackets, colons,
// semi-colons, parenthesis, commas
$chunks = preg_split('/([\'|"]).+(?![^\\\]\\1)\\1/iU', $output, -1, PREG_SPLIT_OFFSET_CAPTURE);
@@ -899,11 +928,11 @@ class CI_Output {
}
}
- if ($value === "'")
+ if ($value === "'" && ! $in_dstring)
{
$in_string = ! $in_string;
}
- elseif ($value === '"')
+ elseif ($value === '"' && ! $in_string)
{
$in_dstring = ! $in_dstring;
}
diff --git a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
index 285fca514..fda3f238b 100644
--- a/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
+++ b/system/database/drivers/pdo/subdrivers/pdo_pgsql_driver.php
@@ -137,7 +137,7 @@ class CI_DB_pdo_pgsql_driver extends CI_DB_pdo_driver {
*/
public function is_write_type($sql)
{
- return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql);
+ return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql));
}
// --------------------------------------------------------------------
diff --git a/system/database/drivers/postgre/postgre_driver.php b/system/database/drivers/postgre/postgre_driver.php
index 010518ed3..dbf7c6b95 100644
--- a/system/database/drivers/postgre/postgre_driver.php
+++ b/system/database/drivers/postgre/postgre_driver.php
@@ -318,7 +318,7 @@ class CI_DB_postgre_driver extends CI_DB {
*/
public function is_write_type($sql)
{
- return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql);
+ return (bool) preg_match('/^\s*"?(SET|INSERT(?![^\)]+\)\s+RETURNING)|UPDATE(?!.*\sRETURNING)|DELETE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', str_replace(array("\r\n", "\r", "\n"), ' ', $sql));
}
// --------------------------------------------------------------------