Skip to content

Commit

Permalink
Fix XSS in recent/favorite tables list feature
Browse files Browse the repository at this point in the history
Signed-off-by: Ann + J.M <phpMyAdmin@ZweiSteinSoft.de>
  • Loading branch information
ZweiSteinSoft committed Jun 6, 2014
1 parent 588bb79 commit cb7c703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
13 changes: 8 additions & 5 deletions libraries/RecentFavoriteTable.class.php
Expand Up @@ -206,8 +206,9 @@ public function getHtmlList()
$html .= '<a href="sql.php?server=' . $GLOBALS['server']
. '&db=' . $table['db']
. '&table=' . $table['table']
. '&token=' . $_SESSION[' PMA_token ']
. '">`' . $table['db'] . '`.`' . $table['table'] . '`</a>';
. '&token=' . $_SESSION[' PMA_token '] . '">`'
. htmlspecialchars($table['db']) . '`.`'
. htmlspecialchars($table['table']) . '`</a>';
$html .= '</li>';
}
} else {
Expand All @@ -223,16 +224,18 @@ public function getHtmlList()
. PMA_URL_getCommon($fav_params);
$html .= 'href="' . $fav_rm_url
. '" title="' . __("Remove from Favorites")
. '" data-favtargetn="' . $table['db'] . "." . $table['table']
. '" data-favtargetn="'
. md5($table['db'] . "." . $table['table'])
. '" >'
. PMA_Util::getIcon('b_favorite.png')
. '</a>';

$html .= '<a href="sql.php?server=' . $GLOBALS['server']
. '&db=' . $table['db']
. '&table=' . $table['table']
. '&token=' . $_SESSION[' PMA_token ']
. '">`' . $table['db'] . '`.`' . $table['table'] . '`</a>';
. '&token=' . $_SESSION[' PMA_token '] . '">`'
. htmlspecialchars($table['db']) . '`.`'
. htmlspecialchars($table['table']) . '`</a>';
$html .= '</li>';
}
}
Expand Down
11 changes: 6 additions & 5 deletions libraries/structure.lib.php
Expand Up @@ -2736,23 +2736,24 @@ function PMA_checkFavoriteTable($db, $current_table)
function PMA_getHtmlForFavoriteAnchor($db, $current_table, $titles)
{
$html_output = '<a ';
$html_output .= 'id="' . preg_replace(
'/\s+/', '', $current_table['TABLE_NAME']
) . '_favorite_anchor" ';
$html_output .= 'id="' . md5($current_table['TABLE_NAME'])
. '_favorite_anchor" ';
$html_output .= 'class="ajax favorite_table_anchor';

// Check if current table is already in favorite list.
$already_favorite = PMA_checkFavoriteTable($db, $current_table['TABLE_NAME']);
$fav_params = array('db' => $db,
'ajax_request' => true,
'favorite_table' => $current_table['TABLE_NAME'],
(($already_favorite?'remove':'add') . '_favorite') => true);
(($already_favorite?'remove':'add') . '_favorite') => true
);
$fav_url = 'db_structure.php' . PMA_URL_getCommon($fav_params);
$html_output .= '" ';
$html_output .= 'href="' . $fav_url
. '" title="' . ($already_favorite ? __("Remove from Favorites")
: __("Add to Favorites"))
. '" data-favtargets="' . $db . "." . $current_table['TABLE_NAME']
. '" data-favtargets="'
. md5($db . "." . $current_table['TABLE_NAME'])
. '" >'
. (!$already_favorite ? $titles['NoFavorite']
: $titles['Favorite']) . '</a>';
Expand Down

0 comments on commit cb7c703

Please sign in to comment.