[Phpmyadmin-git] [SCM] phpMyAdmin branch, master, updated. RELEASE_3_4_9RC1-24875-gc03228e

Marc Delisle lem9 at users.sourceforge.net
Fri Dec 16 18:06:52 CET 2011


The branch, master has been updated
       via  c03228e7f72d9b92fdc0bb504f1e9c68be942c64 (commit)
       via  173d43d15bf58d09e06ed17fd4e3b0bd0734756b (commit)
       via  a9d98907268ed1eb643e2c36780d45f360534500 (commit)
       via  797ec6faf0b6db8103bef1de06890fc357a6c521 (commit)
       via  7ef064f648fbaff787183b2d194981821d72054a (commit)
       via  9fc23c882467bca9809c6e05dd1dd38284b05abd (commit)
       via  e43ed55b045dec9724e0695d7039b7a8aad90a99 (commit)
      from  07472a7f2a726580b02c2c14a7ab852b2ccac90d (commit)


- Log -----------------------------------------------------------------
commit c03228e7f72d9b92fdc0bb504f1e9c68be942c64
Merge: 07472a7 173d43d
Author: Marc Delisle <marc at infomarc.info>
Date:   Fri Dec 16 12:06:10 2011 -0500

    Fix merge conflicts

-----------------------------------------------------------------------

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 85b0d54..62883ec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -67,6 +67,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 32e9b6c..7716d98 100644
--- a/libraries/export/php_array.php
+++ b/libraries/export/php_array.php
@@ -75,7 +75,7 @@ if (isset($plugin_list)) {
      */
     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;
     }
 
@@ -127,6 +127,19 @@ if (isset($plugin_list)) {
         }
         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)) {
@@ -135,16 +148,15 @@ if (isset($plugin_list)) {
 
             // 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




More information about the Git mailing list