Chart import config now returned as application/json to prevent possible XSS attacks

This commit is contained in:
Tyron Madlener 2011-08-05 11:35:09 +03:00
parent af6f02c03b
commit d368a81cca
3 changed files with 11 additions and 10 deletions

View File

@ -9,6 +9,7 @@
require_once './libraries/common.inc.php';
/* For chart exporting */
if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
$allowed = array(
'image/png' => 'png',
@ -53,10 +54,15 @@ if (isset($_REQUEST['filename']) && isset($_REQUEST['image'])) {
/* Send data */
echo $data;
/* For monitor chart config export */
} else if (isset($_REQUEST['monitorconfig'])) {
PMA_download_header('monitor.cfg', 'application/force-download');
echo urldecode($_REQUEST['monitorconfig']);
/* For monitor chart config import */
} else if (isset($_REQUEST['import'])) {
echo '<html><body>' . file_get_contents($_FILES['file']['tmp_name']) . '</body></html>';
header('Content-type: application/json');
if(!file_exists($_FILES['file']['tmp_name'])) exit();
echo file_get_contents($_FILES['file']['tmp_name']);
}
?>
?>

View File

@ -29,13 +29,6 @@ var codemirror_editor = false;
*/
var chart_activeTimeouts = new Object();
if(window.parent) {
$(document).ready(function() {
if(window.parent.currentWidth() == 0)
$('div#frameExpand').show();
});
}
/**
* Add a hidden field to the form to indicate that this will be an
* Ajax request (only if this hidden field does not exist)

View File

@ -1029,7 +1029,9 @@ $(function() {
// Try loading config
try {
json = $.secureEvalJSON($('body',$('iframe#monitorConfigUpload')[0].contentWindow.document).html());
var data = $('body',$('iframe#monitorConfigUpload')[0].contentWindow.document).html();
// Chrome wraps around '<pre style="word-wrap: break-word; white-space: pre-wrap;">' to any text content -.-
json = $.secureEvalJSON(data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1));
} catch (err) {
alert(PMA_messages['strFailedParsingConfig']);
$('div#emptyDialog').dialog('close');