Fix XSS in normalization.js

Signed-off-by: Madhura Jayaratne <madhura.cj@gmail.com>
This commit is contained in:
Madhura Jayaratne 2016-02-25 21:38:32 +11:00 committed by Michal Čihař
parent b3d36dc836
commit f33a42f1da
2 changed files with 19 additions and 1 deletions

View File

@ -243,6 +243,24 @@ function escapeHtml(unsafe) {
}
}
function escapeJsString(unsafe) {
if (typeof(unsafe) != 'undefined') {
return unsafe
.toString()
.replace("\000", '')
.replace('\\', '\\\\')
.replace('\'', '\\\'')
.replace("&#039;", "\\\&#039;")
.replace('"', '\"')
.replace("&quot;", "\&quot;")
.replace("\n", '\n')
.replace("\r", '\r')
.replace(/<\/script/gi, '</\' + \'script')
} else {
return false;
}
}
function PMA_sprintf() {
return sprintf.apply(this, arguments);
}

View File

@ -638,7 +638,7 @@ AJAX.registerOnload('normalization.js', function() {
'</ol>';
$("#newCols").html(confirmStr);
$('.tblFooters').html('<input type="submit" value="' + PMA_messages.strCancel + '" onclick="$(\'#newCols\').html(\'\');$(\'#extra input[type=checkbox]\').removeAttr(\'checked\')"/>' +
'<input type="submit" value="' + PMA_messages.strGo + '" onclick="moveRepeatingGroup(\'' + repeatingCols + '\')"/>');
'<input type="submit" value="' + PMA_messages.strGo + '" onclick="moveRepeatingGroup(\'' + escapeJsString(escapeHtml(repeatingCols)) + '\')"/>');
}
});
$("#mainContent p").on("click", "#createPrimaryKey", function(event) {