Reverted some obfuscated RegExes. Nijel, as you where working on that: I removed the bugfixes you threw in for my faulty code because there where some issue left (for me):

The lines

$re0 = '@(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards
$re1 = '@(^|[^\])(\\\)+'; // escaped wildcards

as they currently where made no sense to me, because the single [^\] should be replaced to [^\\\\] as well, doesn't it? To not seriously break more stuff I decided to revert to the previous mechanism here.

I will do more serious tests the next days and will actually work with my PMA again and I pay close attention to see if there are any issues left.

I also searched through the code to see if the setting of the array points from former while() constructs was in any way used [current(), next(), prev(), key(), end(), each()] but did find none.
This commit is contained in:
Garvin Hicking
2003-11-25 19:20:20 +00:00
parent 4fbe46dc40
commit 8d1bfe6f3b
17 changed files with 34 additions and 38 deletions

View File

@@ -5,6 +5,17 @@ phpMyAdmin - Changelog
$Id$
$Source$
2003-11-24 Garvin Hicking <phpmyadminismyaeroplane@supergarv.de>
* db_details_qbe.php, left.php, main.php, pdf_pages.php, server_collations.php,
tbl_change.php, tbl_indexes.php, tbl_move_copy.php, tbl_relation.php,
tbl_replace.php, libraries/common.lib.php, libraries/db_config.lib.php,
libraries/display_tbl.lib.php, libraries/grab_globals.lib.php,
libraries/mysql_charsets.lib.php, libraries/select_lang.lib.php:
Reverted some obfuscated regular expressions to their working eregi-versions
to not break stuff. Removed unneccessary reset() calls, replaced some more
while(list()) constructs.
2003-11-24 Alexander M. Turek <bloodsugarsexmagik@derrabus.de>
* lang/german-*.inc.php: Updates.
* lang/english-*.inc.php: Sortation.

View File

@@ -862,7 +862,6 @@ if (isset($Field) && count($Field) > 0) {
} else {
reset($col_cand);
$master = current($col_cand); // Only one single candidate
//
}
} // end if (exactly one where clause)

View File

@@ -484,7 +484,6 @@ if ($num_dbs > 1) {
if (!empty($cfg['LeftFrameTableSeparator'])) {
$_table = explode($cfg['LeftFrameTableSeparator'], str_replace('\'', '\\\'',$table));
if (is_array($_table)) {
reset($_table);
foreach($_table AS $key => $val) {
if ($val == '') {
$_table[$key] = '__protected__';

View File

@@ -651,11 +651,11 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// loic1: fixed bad regexp
// TODO: db names may contain characters
// that are regexp instructions
$re = '@(^|(\\\\\\\\)+|[^\])';
$uva_regex = preg_replace($re . '%@', '\\1.*', preg_replace($re . '_@', '\\1.{1}', $uva_matchpattern));
$re = '(^|(\\\\\\\\)+|[^\])';
$uva_regex = ereg_replace($re . '%', '\\1.*', ereg_replace($re . '_', '\\1.{1}', $uva_matchpattern));
// Fixed db name matching
// 2000-08-28 -- Benjamin Gandon
if (preg_match('@^' . $uva_regex . '$@', $uva_db)) {
if (ereg('^' . $uva_regex . '$', $uva_db)) {
$dblist[] = $uva_db;
break;
}
@@ -1104,7 +1104,7 @@ h1 {font-family: sans-serif; font-size: large; font-weight: bold}
// We don't want more than one asterisk inside our 'only_db'.
continue;
}
if ($is_show_dbs && preg_match('@(^|[^\\\\])(_|%)@', $dblist[$i])) {
if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) {
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
$rs = PMA_mysql_query($local_query, $dbh);
// "SHOW DATABASES" statement is disabled

View File

@@ -25,7 +25,7 @@ if (!defined('PMA_DB_CONFIG_LIB_INCLUDED')) {
*/
function obj2xml($v, $indent = '') {
$attr = '';
while (list($key, $val) = each($v)) {
foreach($v AS $key => $val) {
if (is_string($key) && ($key == '__attr')) {
continue;
}

View File

@@ -985,8 +985,7 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
echo ' <td>&nbsp;</td>' . "\n";
}
reset($vertical_display['desc']);
while (list($key, $val) = each($vertical_display['desc'])) {
foreach($vertical_display['desc'] AS $key => $val) {
echo $val;
}
@@ -1544,8 +1543,6 @@ if (!defined('PMA_DISPLAY_TBL_LIB_INCLUDED')) {
{
global $vertical_display, $repeat_cells;
reset($vertical_display);
// Displays "multi row delete" link at top if required
if ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && is_array($vertical_display['row_delete']) && (count($vertical_display['row_delete']) > 0 || !empty($vertical_display['textbtn']))) {
echo '<tr>' . "\n";

View File

@@ -31,7 +31,6 @@ if (!defined('PMA_GRAB_GLOBALS_INCLUDED')) {
$target[$key] = $value;
}
}
reset($array);
return TRUE;
}

View File

@@ -36,14 +36,12 @@ if (!defined('PMA_MYSQL_CHARSETS_LIB_INCLUDED')){
}
}
reset($mysql_collations);
$mysql_collations_count = 0;
while (list($key, $value) = each($mysql_collations)) {
foreach($mysql_collations AS $key => $value) {
$mysql_collations_count += count($mysql_collations[$key]);
sort($mysql_collations[$key], SORT_STRING);
reset($mysql_collations[$key]);
}
reset($mysql_collations);
@mysql_free_result($res);
unset($res);

View File

@@ -174,8 +174,8 @@ if (!defined('PMA_SELECT_LANG_LIB_INCLUDED')) {
foreach($available_languages AS $key => $value) {
// $envType = 1 for the 'HTTP_ACCEPT_LANGUAGE' environment variable,
// 2 for the 'HTTP_USER_AGENT' one
if (($envType == 1 && preg_match('@^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$@i', $str))
|| ($envType == 2 && preg_match('@(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))@i', $str))) {
if (($envType == 1 && eregi('^(' . $value[0] . ')(;q=[0-9]\\.[0-9])?$', $str))
|| ($envType == 2 && eregi('(\(|\[|;[[:space:]])(' . $value[0] . ')(;|\]|\))', $str))) {
$lang = $key;
break;
}

View File

@@ -209,13 +209,13 @@ if ($server > 0) {
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\'';
$rs_usr = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
if ($rs_usr) {
$re0 = '@(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '@(^|[^\])(\\\)+'; // escaped wildcards
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_mysql_fetch_array($rs_usr)) {
if (preg_match($re0 . '(%|_)@', $row['Db'])
|| (!PMA_mysql_select_db(preg_replace($re1 . '(%|_)@', '\\1\\3', $row['Db']), $userlink) && @mysql_errno() != 1044)) {
$db_to_create = preg_replace($re0 . '%@', '\\1...', preg_replace($re0 . '_@', '\\1?', $row['Db']));
$db_to_create = preg_replace($re1 . '(%|_)@', '\\1\\3', $db_to_create);
if (ereg($re0 . '(%|_)', $row['Db'])
|| (!PMA_mysql_select_db(ereg_replace($re1 . '(%|_)', '\\1\\3', $row['Db']), $userlink) && @mysql_errno() != 1044)) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $row['Db']));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_priv = TRUE;
break;
} // end if
@@ -235,8 +235,8 @@ if ($server > 0) {
$rs_usr = PMA_mysql_query($local_query, $dbh);
}
if ($rs_usr) {
$re0 = '@(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards
$re1 = '@(^|[^\])(\\\)+'; // escaped wildcards
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
while ($row = PMA_mysql_fetch_row($rs_usr)) {
$show_grants_dbname = substr($row[0], strpos($row[0], ' ON ') + 4,(strpos($row[0], '.', strpos($row[0], ' ON ')) - strpos($row[0], ' ON ') - 4));
$show_grants_str = substr($row[0],6,(strpos($row[0],' ON ')-6));
@@ -246,9 +246,9 @@ if ($server > 0) {
$db_to_create = '';
break;
} // end if
else if (preg_match($re0 . '%|_@', $show_grants_dbname) || !PMA_mysql_select_db($show_grants_dbname, $userlink) && @mysql_errno() != 1044) {
$db_to_create = preg_replace($re0 . '%@', '\\1...', preg_replace($re0 . '_@', '\\1?', $show_grants_dbname));
$db_to_create = preg_replace($re1 . '(%|_)@', '\\1\\3', $db_to_create);
else if (preg_match($re0 . '%|_', $show_grants_dbname) || !PMA_mysql_select_db($show_grants_dbname, $userlink) && @mysql_errno() != 1044) {
$db_to_create = ereg_replace($re0 . '%', '\\1...', ereg_replace($re0 . '_', '\\1?', $show_grants_dbname));
$db_to_create = ereg_replace($re1 . '(%|_)', '\\1\\3', $db_to_create);
$is_create_priv = TRUE;
break;
} // end elseif

View File

@@ -295,7 +295,6 @@ $i = 0;
while ($temp_sh_page = @PMA_mysql_fetch_array($page_rs)) {
$array_sh_page[] = $temp_sh_page;
}
reset($array_sh_page);
// garvin: Display WYSIWYG-PDF parts?
if ($cfg['WYSIWYG-PDF']) {
@@ -384,7 +383,6 @@ function resetDrag() {
echo '>';
echo "\n" . ' <td>'
. "\n" . ' <select name="c_table_' . $i . '[name]">';
reset($selectboxall);
foreach($selectboxall AS $key => $value) {
echo "\n" . ' <option value="' . $value . '"';
if ($value == $sh_page['table_name']) {

View File

@@ -55,8 +55,6 @@ echo '<table border="0">' . "\n"
. ' </th>' . "\n"
. ' </tr>' . "\n";
reset($mysql_charsets);
reset($mysql_collations);
$i = 0;
$table_row_count = count($mysql_charsets) + $mysql_collations_count;

View File

@@ -220,7 +220,8 @@ for ($i = 0; $i < $fields_cnt; $i++) {
echo "\n";
$row_table_def = PMA_mysql_fetch_array($table_def);
$row_table_def['True_Type'] = preg_replace('@\\(.*@', '', $row_table_def['Type']);
$row_table_def['True_Type'] = preg_replace('@\(.*@', '', $row_table_def['Type']);
$field = $row_table_def['Field'];
// garvin: possible workaround. If current field is numerical, do not try to

View File

@@ -127,7 +127,7 @@ while ($row = PMA_mysql_fetch_array($fields_rs)) {
$fields_names[] = $row['Field'];
// loic1: set or enum types: slashes single quotes inside options
if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
$tmp[2] = substr(preg_replace('@([^,])\'\@', '\\1\\\'', ',' . $tmp[2]), 1);
$tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
$fields_types[] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
} else {
$fields_types[] = $row['Type'];
@@ -352,7 +352,6 @@ else if (!defined('PMA_IDX_INCLUDED')
<option value="--ignore--"<?php if ('--ignore--' == $selected) echo ' selected="selected"'; ?>>
-- <?php echo $strIgnore; ?> --</option>
<?php
reset($fields_names);
foreach($fields_names AS $key => $val) {
if ($index_type != 'FULLTEXT'
|| preg_match('@^(varchar|text|tinytext|mediumtext|longtext)@i', $fields_types[$key])) {

View File

@@ -57,7 +57,6 @@ global $cfgRelation;
$last_id = -1;
if ($cfgRelation[$work]) {
@reset($get_fields);
$select_parts = array();
$row_fields = array();
foreach($get_fields AS $nr => $get_field) {

View File

@@ -379,7 +379,6 @@ if ($col_rs && mysql_num_rows($col_rs) > 0) {
echo "\n";
// PMA internal relations
reset($selectboxall);
if (isset($existrel[$myfield])) {
$foreign_field = $existrel[$myfield]['foreign_db'] . '.'
. $existrel[$myfield]['foreign_table'] . '.'

View File

@@ -62,7 +62,6 @@ if (isset($err_url)) {
}
// Resets tables defined in the configuration file
reset($fields);
if (isset($funcs)) {
reset($funcs);
}