From dea9bc31fe05fb1d5ea34776173fa6d47577db80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Thu, 19 Oct 2006 15:57:17 +0000 Subject: [PATCH] Fix escaping of long query with js (thanks to Erwin for report). --- ChangeLog | 4 ++++ libraries/common.lib.php | 33 +++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9badab8ce..7b489b940 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - ChangeLog $Id$ $Source$ +2006-10-19 Michal Čihař + * libraries/common.lib.php: Fix escaping of long query with js (thanks to + Erwin for report). + 2006-10-18 Marc Delisle * db_operations.php, libraries/Table.class.php: bug #1567316, renaming a db containing a view diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 8a40534fb..596ad946e 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1395,19 +1395,20 @@ if (!defined('PMA_MINIMUM_COMMON')) { /** * escapes a string to be inserted as string a JavaScript block * enclosed by - * this requires only to escape ' with \' + * this requires only to escape ' with \' and end of script block * - * @uses str_replace() + * @uses strtr() * @param string $string the string to be escaped * @return string the escaped string */ function PMA_escapeJsString($string) { - $string = str_replace('\\', '\\\\', $string); - $string = str_replace('\'', '\\\'', $string); - $string = str_replace("\012", '\n', $string); - $string = str_replace("\015", '\r', $string); - return $string; + return strtr($string, array( + '\\' => '\\\\', + '\'' => '\\\'', + "\n" => '\n', + "\r" => '\r', + ' '<\' + \'script')); } /** @@ -1544,7 +1545,15 @@ window.parent.updateTableTitle('', '', '