Merge branch 'QA_3_3'
Conflicts: libraries/core.lib.php server_databases.php server_privileges.php
This commit is contained in:
@@ -119,6 +119,9 @@ $Id$
|
||||
- bug #3044189 [doc] Cleared documentation for hide_db.
|
||||
- bug #3042495 [core] Move PMA_sendHeaderLocation to core.lib.php.
|
||||
|
||||
3.3.5.1 (2010-10-20)
|
||||
- [core] Fixed various XSS issues, see PMASA-2010-5 for more details.
|
||||
|
||||
3.3.5.0 (2010-07-26)
|
||||
- patch #2932113 [information_schema] Slow export when having lots of
|
||||
databases, thanks to Stéphane Pontier - shadow_walker
|
||||
|
@@ -336,7 +336,7 @@ $alter_select =
|
||||
<tr><td align="right">
|
||||
<?php echo __('Inside column:'); ?></td>
|
||||
<td><input type="text" name="field_str" size="60"
|
||||
value="<?php echo ! empty($field_str) ? $field_str : ''; ?>" /></td>
|
||||
value="<?php echo ! empty($field_str) ? htmlspecialchars($field_str) : ''; ?>" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
@@ -36,7 +36,7 @@ if ($num_tables == 0 && empty($db_query_force)) {
|
||||
/**
|
||||
* Query box, bookmark, insert data from textfile
|
||||
*/
|
||||
PMA_sqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? $_REQUEST['delimiter'] : ';');
|
||||
PMA_sqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';');
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
|
@@ -75,10 +75,14 @@ header('Content-Type: text/html; charset=' . $charset);
|
||||
<body>
|
||||
<h1>phpMyAdmin - <?php echo $type; ?></h1>
|
||||
<p><?php
|
||||
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
|
||||
if (!empty($_REQUEST['error'])) {
|
||||
if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc()) {
|
||||
echo PMA_sanitize(stripslashes($_REQUEST['error']));
|
||||
} else {
|
||||
} else {
|
||||
echo PMA_sanitize($_REQUEST['error']);
|
||||
}
|
||||
} else {
|
||||
echo 'No error message!';
|
||||
}
|
||||
?></p>
|
||||
</body>
|
||||
|
@@ -566,7 +566,7 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
|
||||
$formatted_sql = '';
|
||||
} else {
|
||||
if (strlen($the_query) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
|
||||
$formatted_sql = substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]';
|
||||
$formatted_sql = htmlspecialchars(substr($the_query, 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) . '[...]';
|
||||
} else {
|
||||
$formatted_sql = PMA_formatSql(PMA_SQP_parse($the_query), $the_query);
|
||||
}
|
||||
|
@@ -525,22 +525,23 @@ function PMA_getenv($var_name) {
|
||||
function PMA_sendHeaderLocation($uri)
|
||||
{
|
||||
if (PMA_IS_IIS && strlen($uri) > 600) {
|
||||
require_once './libraries/js_escape.lib.php';
|
||||
|
||||
echo '<html><head><title>- - -</title>' . "\n";
|
||||
echo '<meta http-equiv="expires" content="0">' . "\n";
|
||||
echo '<meta http-equiv="Pragma" content="no-cache">' . "\n";
|
||||
echo '<meta http-equiv="Cache-Control" content="no-cache">' . "\n";
|
||||
echo '<meta http-equiv="Refresh" content="0;url=' .$uri . '">' . "\n";
|
||||
echo '<meta http-equiv="Refresh" content="0;url=' . htmlspecialchars($uri) . '">' . "\n";
|
||||
echo '<script type="text/javascript">' . "\n";
|
||||
echo '//<![CDATA[' . "\n";
|
||||
echo 'setTimeout("window.location = unescape(\'"' . $uri . '"\')", 2000);' . "\n";
|
||||
echo 'setTimeout("window.location = unescape(\'"' . PMA_escapeJsString($uri) . '"\')", 2000);' . "\n";
|
||||
echo '//]]>' . "\n";
|
||||
echo '</script>' . "\n";
|
||||
echo '</head>' . "\n";
|
||||
echo '<body>' . "\n";
|
||||
echo '<script type="text/javascript">' . "\n";
|
||||
echo '//<![CDATA[' . "\n";
|
||||
echo 'document.write(\'<p><a href="' . $uri . '">' . __('Go') . '</a></p>\');' . "\n";
|
||||
echo 'document.write(\'<p><a href="' . htmlspecialchars($uri) . '">' . __('Go') . '</a></p>\');' . "\n";
|
||||
echo '//]]>' . "\n";
|
||||
echo '</script></body></html>' . "\n";
|
||||
|
||||
|
@@ -195,6 +195,10 @@ function PMA_usort_comparison_callback($a, $b)
|
||||
} else {
|
||||
$sorter = 'strcasecmp';
|
||||
}
|
||||
/* No sorting when key is not present */
|
||||
if (!isset($a[$GLOBALS['callback_sort_by']]) || ! isset($b[$GLOBALS['callback_sort_by']])) {
|
||||
return 0;
|
||||
}
|
||||
// produces f.e.:
|
||||
// return -1 * strnatcasecmp($a["SCHEMA_TABLES"], $b["SCHEMA_TABLES"])
|
||||
return ($GLOBALS['callback_sort_order'] == 'ASC' ? 1 : -1) * $sorter($a[$GLOBALS['callback_sort_by']], $b[$GLOBALS['callback_sort_by']]);
|
||||
|
@@ -211,7 +211,8 @@ if (! isset($sot_ready)) {
|
||||
);
|
||||
|
||||
// Make sure the sort type is implemented
|
||||
if ($sort = $sortable_name_mappings[$_REQUEST['sort']]) {
|
||||
if (isset($sortable_name_mappings[$_REQUEST['sort']])) {
|
||||
$sort = $sortable_name_mappings[$_REQUEST['sort']];
|
||||
if ($_REQUEST['sort_order'] == 'DESC') {
|
||||
$sort_order = 'DESC';
|
||||
}
|
||||
|
@@ -344,6 +344,8 @@ function PMA_DBI_getError($link = null)
|
||||
$error_message = PMA_DBI_convert_message($error_message);
|
||||
}
|
||||
|
||||
$error_message = htmlspecialchars($error_message);
|
||||
|
||||
// Some errors messages cannot be obtained by mysql_error()
|
||||
if ($error_number == 2002) {
|
||||
$error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding') . ' ' . __('(or the local MySQL server\'s socket is not correctly configured)');
|
||||
|
@@ -400,6 +400,8 @@ function PMA_DBI_getError($link = null)
|
||||
$error_message = PMA_DBI_convert_message($error_message);
|
||||
}
|
||||
|
||||
$error_message = htmlspecialchars($error_message);
|
||||
|
||||
if ($error_number == 2002) {
|
||||
$error = '#' . ((string) $error_number) . ' - ' . __('The server is not responding') . ' ' . __('(or the local MySQL server\'s socket is not correctly configured)');
|
||||
} else {
|
||||
|
@@ -8,17 +8,26 @@
|
||||
|
||||
/**
|
||||
* Sanitizes $message, taking into account our special codes
|
||||
* for formatting
|
||||
* for formatting.
|
||||
*
|
||||
* If you want to include result in element attribute, you should escape it.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* <p><?php echo PMA_sanitize($foo); ?></p>
|
||||
*
|
||||
* <a title="<?php echo PMA_sanitize($foo, true); ?>">bar</a>
|
||||
*
|
||||
* @uses preg_replace()
|
||||
* @uses strtr()
|
||||
* @param string the message
|
||||
* @param boolean whether to escape html in result
|
||||
*
|
||||
* @return string the sanitized message
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function PMA_sanitize($message)
|
||||
function PMA_sanitize($message, $escape = false)
|
||||
{
|
||||
$replace_pairs = array(
|
||||
'<' => '<',
|
||||
@@ -66,6 +75,10 @@ function PMA_sanitize($message)
|
||||
$message = preg_replace($pattern, '<a href="\1" target="\2">', $message);
|
||||
}
|
||||
|
||||
if ($escape) {
|
||||
$message = htmlspecialchars($message);
|
||||
}
|
||||
|
||||
return $message;
|
||||
}
|
||||
?>
|
||||
|
@@ -2574,7 +2574,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
}
|
||||
$after .= "\n";
|
||||
*/
|
||||
$str .= $before . ($mode=='color' ? PMA_SQP_formatHTML_colorize($arr[$i]) : $arr[$i]['data']). $after;
|
||||
$str .= $before . ($mode=='color' ? PMA_SQP_formatHTML_colorize($arr[$i]) : htmlspecialchars($arr[$i]['data'])). $after;
|
||||
} // end for
|
||||
/* End possibly unclosed documentation link */
|
||||
if ($close_docu_link) {
|
||||
|
@@ -19,7 +19,21 @@ require './libraries/replication.inc.php';
|
||||
if (empty($_REQUEST['sort_by'])) {
|
||||
$sort_by = 'SCHEMA_NAME';
|
||||
} else {
|
||||
$sort_by = PMA_sanitize($_REQUEST['sort_by']);
|
||||
$sort_by_whitelist = array(
|
||||
'SCHEMA_NAME',
|
||||
'DEFAULT_COLLATION_NAME',
|
||||
'SCHEMA_TABLES',
|
||||
'SCHEMA_TABLE_ROWS',
|
||||
'SCHEMA_DATA_LENGTH',
|
||||
'SCHEMA_INDEX_LENGTH',
|
||||
'SCHEMA_LENGTH',
|
||||
'SCHEMA_DATA_FREE'
|
||||
);
|
||||
if (in_array($_REQUEST['sort_by'], $sort_by_whitelist)) {
|
||||
$sort_by = $_REQUEST['sort_by'];
|
||||
} else {
|
||||
$sort_by = 'SCHEMA_NAME';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['sort_order'])
|
||||
@@ -339,11 +353,11 @@ if ($databases_count > 0) {
|
||||
unset($column_order, $stat_name, $stat, $databases, $table_columns);
|
||||
|
||||
if ($is_superuser || $cfg['AllowUserDropDatabase']) {
|
||||
$common_url_query = PMA_generate_common_url() . '&sort_by=' . $sort_by . '&sort_order=' . $sort_order . '&dbstats=' . $dbstats;
|
||||
$common_url_query = PMA_generate_common_url(array('sort_by' => $sort_by, 'sort_order' => $sort_order, 'dbstats' => $dbstats));
|
||||
echo '<img class="selectallarrow" src="' . $pmaThemeImage . 'arrow_' . $text_dir . '.png" width="38" height="22" alt="' . __('With selected:') . '" />' . "\n"
|
||||
. '<a href="./server_databases.php?' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
|
||||
. '<a href="./server_databases.php' . $common_url_query . '&checkall=1" onclick="if (markAllRows(\'tabledatabases\')) return false;">' . "\n"
|
||||
. ' ' . __('Check All') . '</a> / ' . "\n"
|
||||
. '<a href="./server_databases.php?' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
|
||||
. '<a href="./server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
|
||||
. ' ' . __('Uncheck All') . '</a>' . "\n"
|
||||
. '<i>' . __('With selected:') . '</i>' . "\n";
|
||||
PMA_buttonOrImage('drop_selected_dbs', 'mult_submit', 'drop_selected_dbs', __('Drop'), 'b_deltbl.png');
|
||||
|
@@ -1182,7 +1182,7 @@ if (!empty($update_privs)) {
|
||||
}
|
||||
$sql_query = $sql_query0 . ' ' . $sql_query1 . ' ' . $sql_query2;
|
||||
$message = PMA_Message::success(__('You have updated the privileges for %s.'));
|
||||
$message->addParam('\'' . $username . '\'@\'' . $hostname . '\'');
|
||||
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
|
||||
}
|
||||
|
||||
|
||||
@@ -1206,7 +1206,7 @@ if (isset($_REQUEST['revokeall'])) {
|
||||
}
|
||||
$sql_query = $sql_query0 . ' ' . $sql_query1;
|
||||
$message = PMA_Message::success(__('You have revoked the privileges for %s'));
|
||||
$message->addParam('\'' . $username . '\'@\'' . $hostname . '\'');
|
||||
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
|
||||
if (! isset($tablename)) {
|
||||
unset($dbname);
|
||||
} else {
|
||||
@@ -1242,7 +1242,7 @@ if (isset($_REQUEST['change_pw'])) {
|
||||
PMA_DBI_try_query($local_query)
|
||||
or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, FALSE, $err_url);
|
||||
$message = PMA_Message::success(__('The password for %s was changed successfully.'));
|
||||
$message->addParam('\'' . $username . '\'@\'' . $hostname . '\'');
|
||||
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1647,8 +1647,8 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
|
||||
if (isset($dbname)) {
|
||||
echo ' <i><a href="server_privileges.php?'
|
||||
. $GLOBALS['url_query'] . '&username=' . urlencode($username)
|
||||
. '&hostname=' . urlencode($hostname) . '&dbname=&tablename=">\''
|
||||
. $GLOBALS['url_query'] . '&username=' . htmlspecialchars(urlencode($username))
|
||||
. '&hostname=' . htmlspecialchars(urlencode($hostname)) . '&dbname=&tablename=">\''
|
||||
. htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname)
|
||||
. '\'</a></i>' . "\n";
|
||||
$url_dbname = urlencode(str_replace(array('\_', '\%'), array('_', '%'), $dbname));
|
||||
@@ -1656,8 +1656,8 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
echo ' - ' . ($dbname_is_wildcard ? __('Databases') : __('Database') );
|
||||
if (isset($tablename)) {
|
||||
echo ' <i><a href="server_privileges.php?' . $GLOBALS['url_query']
|
||||
. '&username=' . urlencode($username) . '&hostname=' . urlencode($hostname)
|
||||
. '&dbname=' . $url_dbname . '&tablename=">' . htmlspecialchars($dbname) . '</a></i>';
|
||||
. '&username=' . htmlspecialchars(urlencode($username)) . '&hostname=' . htmlspecialchars(urlencode($hostname))
|
||||
. '&dbname=' . htmlspecialchars($url_dbname) . '&tablename=">' . htmlspecialchars($dbname) . '</a></i>';
|
||||
echo ' - ' . __('Table') . ' <i>' . htmlspecialchars($tablename) . '</i>';
|
||||
} else {
|
||||
echo ' <i>' . htmlspecialchars($dbname) . '</i>';
|
||||
@@ -1891,16 +1891,16 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
}
|
||||
echo '</td>' . "\n"
|
||||
. ' <td>';
|
||||
printf($link_edit, urlencode($username),
|
||||
urlencode($hostname),
|
||||
urlencode((! isset($dbname)) ? $row['Db'] : $dbname),
|
||||
printf($link_edit, htmlspecialchars(urlencode($username)),
|
||||
urlencode(htmlspecialchars($hostname)),
|
||||
urlencode((! isset($dbname)) ? $row['Db'] : htmlspecialchars($dbname)),
|
||||
urlencode((! isset($dbname)) ? '' : $row['Table_name']));
|
||||
echo '</td>' . "\n"
|
||||
. ' <td>';
|
||||
if (! empty($row['can_delete']) || isset($row['Table_name']) && strlen($row['Table_name'])) {
|
||||
printf($link_revoke, urlencode($username),
|
||||
urlencode($hostname),
|
||||
urlencode((! isset($dbname)) ? $row['Db'] : $dbname),
|
||||
printf($link_revoke, htmlspecialchars(urlencode($username)),
|
||||
urlencode(htmlspecialchars($hostname)),
|
||||
urlencode((! isset($dbname)) ? $row['Db'] : htmlspecialchars($dbname)),
|
||||
urlencode((! isset($dbname)) ? '' : $row['Table_name']));
|
||||
}
|
||||
echo '</td>' . "\n"
|
||||
@@ -1980,7 +1980,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
if (isset($tablename)) {
|
||||
echo ' [ ' . __('Table') . ' <a href="'
|
||||
. $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query']
|
||||
. '&db=' . $url_dbname . '&table=' . urlencode($tablename)
|
||||
. '&db=' . $url_dbname . '&table=' . htmlspecialchars(urlencode($tablename))
|
||||
. '&reload=1">' . htmlspecialchars($tablename) . ': '
|
||||
. PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])
|
||||
. "</a> ]\n";
|
||||
@@ -2207,7 +2207,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
|
||||
|
||||
// Offer to create a new user for the current database
|
||||
echo '<fieldset id="fieldset_add_user">' . "\n"
|
||||
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&adduser=1&dbname=' . $checkprivs .'">' . "\n"
|
||||
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&adduser=1&dbname=' . htmlspecialchars($checkprivs) .'">' . "\n"
|
||||
. PMA_getIcon('b_usradd.png')
|
||||
. ' ' . __('Add a new User') . '</a>' . "\n"
|
||||
. '</fieldset>' . "\n";
|
||||
|
14
sql.php
14
sql.php
@@ -173,14 +173,14 @@ if ($do_confirm) {
|
||||
.PMA_generate_common_hidden_inputs($db, $table);
|
||||
?>
|
||||
<input type="hidden" name="sql_query" value="<?php echo htmlspecialchars($sql_query); ?>" />
|
||||
<input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows) : ''; ?>" />
|
||||
<input type="hidden" name="zero_rows" value="<?php echo isset($zero_rows) ? PMA_sanitize($zero_rows, true) : ''; ?>" />
|
||||
<input type="hidden" name="goto" value="<?php echo $goto; ?>" />
|
||||
<input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back) : ''; ?>" />
|
||||
<input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload) : 0; ?>" />
|
||||
<input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge) : ''; ?>" />
|
||||
<input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge) : ''; ?>" />
|
||||
<input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey) : ''; ?>" />
|
||||
<input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query) : ''; ?>" />
|
||||
<input type="hidden" name="back" value="<?php echo isset($back) ? PMA_sanitize($back, true) : ''; ?>" />
|
||||
<input type="hidden" name="reload" value="<?php echo isset($reload) ? PMA_sanitize($reload, true) : 0; ?>" />
|
||||
<input type="hidden" name="purge" value="<?php echo isset($purge) ? PMA_sanitize($purge, true) : ''; ?>" />
|
||||
<input type="hidden" name="cpurge" value="<?php echo isset($cpurge) ? PMA_sanitize($cpurge, true) : ''; ?>" />
|
||||
<input type="hidden" name="purgekey" value="<?php echo isset($purgekey) ? PMA_sanitize($purgekey, true) : ''; ?>" />
|
||||
<input type="hidden" name="show_query" value="<?php echo isset($show_query) ? PMA_sanitize($show_query, true) : ''; ?>" />
|
||||
<?php
|
||||
echo '<fieldset class="confirmation">' . "\n"
|
||||
.' <legend>' . __('Do you really want to ') . '</legend>'
|
||||
|
@@ -37,7 +37,7 @@ require_once './libraries/tbl_links.inc.php';
|
||||
/**
|
||||
* Query box, bookmark, insert data from textfile
|
||||
*/
|
||||
PMA_sqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? $_REQUEST['delimiter'] : ';');
|
||||
PMA_sqlQueryForm(true, false, isset($_REQUEST['delimiter']) ? htmlspecialchars($_REQUEST['delimiter']) : ';');
|
||||
|
||||
/**
|
||||
* Displays the footer
|
||||
|
Reference in New Issue
Block a user