The branch, QA_3_4 has been updated
via 173d43d15bf58d09e06ed17fd4e3b0bd0734756b (commit)
via a9d98907268ed1eb643e2c36780d45f360534500 (commit)
via 797ec6faf0b6db8103bef1de06890fc357a6c521 (commit)
via 7ef064f648fbaff787183b2d194981821d72054a (commit)
via 9fc23c882467bca9809c6e05dd1dd38284b05abd (commit)
via e43ed55b045dec9724e0695d7039b7a8aad90a99 (commit)
from 5130615c0a94a3a13d9e97c3845c408732bfc019 (commit)
- Log -----------------------------------------------------------------
commit 173d43d15bf58d09e06ed17fd4e3b0bd0734756b
Author: Marc Delisle <marc(a)infomarc.info>
Date: Fri Dec 16 11:40:56 2011 -0500
patch #3375984 [export] PHP Array export might generate invalid php code
commit a9d98907268ed1eb643e2c36780d45f360534500
Author: Sven Strickroth <email(a)cs-ware.de>
Date: Wed Dec 14 16:16:31 2011 +0100
fixed typo
Signed-off-by: Sven Strickroth <email(a)cs-ware.de>
commit 797ec6faf0b6db8103bef1de06890fc357a6c521
Author: Sven Strickroth <email(a)cs-ware.de>
Date: Sat Jul 23 04:04:41 2011 +0200
added spaces to improve look and feel of output
Signed-off-by: Sven Strickroth <email(a)cs-ware.de>
commit 7ef064f648fbaff787183b2d194981821d72054a
Author: Sven Strickroth <email(a)cs-ware.de>
Date: Sat Jul 23 04:04:23 2011 +0200
add backquotes to improve look and feel of output
Signed-off-by: Sven Strickroth <email(a)cs-ware.de>
commit 9fc23c882467bca9809c6e05dd1dd38284b05abd
Author: Sven Strickroth <email(a)cs-ware.de>
Date: Sat Jul 23 03:56:36 2011 +0200
escape single quotes in column names
Column names like `id'` must be escaped in a PHP string
Signed-off-by: Sven Strickroth <email(a)cs-ware.de>
commit e43ed55b045dec9724e0695d7039b7a8aad90a99
Author: Sven Strickroth <email(a)cs-ware.de>
Date: Sat Jul 23 03:55:13 2011 +0200
fix invalid PHP variable names
Tables with names like `0-` are allowed in SQL, but not in PHP variable names
Signed-off-by: Sven Strickroth <email(a)cs-ware.de>
-----------------------------------------------------------------------
Summary of changes:
ChangeLog | 1 +
libraries/export/php_array.php | 22 +++++++++++++++++-----
2 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 86b6965..c51c785 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ phpMyAdmin - ChangeLog
3.4.10.0 (not yet released)
- bug #3460090 [interface] TextareaAutoSelect feature broken
+- patch #3375984 [export] PHP Array export might generate invalid php code
3.4.9.0 (not yet released)
- bug #3442028 [edit] Inline editing enum fields with null shows no dropdown
diff --git a/libraries/export/php_array.php b/libraries/export/php_array.php
index 983673c..5b5937d 100644
--- a/libraries/export/php_array.php
+++ b/libraries/export/php_array.php
@@ -87,7 +87,7 @@ function PMA_exportHeader()
*/
function PMA_exportDBHeader($db)
{
- PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database
"' . $db . '"' . $GLOBALS['crlf'] . '//' .
$GLOBALS['crlf']);
+ PMA_exportOutputHandler('//' . $GLOBALS['crlf'] . '// Database
' . PMA_backquote($db) . $GLOBALS['crlf'] . '//' .
$GLOBALS['crlf']);
return true;
}
@@ -142,6 +142,19 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
}
unset($i);
+ // fix variable names (based on
http://www.php.net/manual/language.variables.basics.php)
+ if (preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $table) ==
false) {
+ // fix invalid chars in variable names by replacing them with underscores
+ $tablefixed = preg_replace('/[^a-zA-Z0-9_\x7f-\xff]/', '_',
$table);
+
+ // variable name must not start with a number or dash...
+ if (preg_match('/^[a-zA-Z_\x7f-\xff]/', $tablefixed) == false) {
+ $tablefixed = '_' . $tablefixed;
+ }
+ } else {
+ $tablefixed = $table;
+ }
+
$buffer = '';
$record_cnt = 0;
while ($record = PMA_DBI_fetch_row($result)) {
@@ -150,16 +163,15 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
- $buffer .= $crlf . '// ' . $db . '.' . $table . $crlf;
- $buffer .= '$' . $table . ' = array(' . $crlf;
+ $buffer .= $crlf . '// ' . PMA_backquote($db) . '.' .
PMA_backquote($table) . $crlf;
+ $buffer .= '$' . $tablefixed . ' = array(' . $crlf;
$buffer .= ' array(';
} else {
$buffer .= ',' . $crlf . ' array(';
}
-
for ($i = 0; $i < $columns_cnt; $i++) {
- $buffer .= "'" . $columns[$i]. "'=>" .
var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
+ $buffer .= var_export($columns[$i], true) . " => " .
var_export($record[$i], true) . (($i + 1 >= $columns_cnt) ? '' : ',');
}
$buffer .= ')';
hooks/post-receive
--
phpMyAdmin