Escape HTML in js-generated confirmation messages

This commit is contained in:
Marc Delisle
2011-09-08 15:38:40 -04:00
parent 2f28ce9c80
commit bda213c58a
3 changed files with 17 additions and 5 deletions

View File

@@ -172,7 +172,7 @@ function selectContent( element, lock, only_once ) {
}
/**
* Displays a confirmation box before to submit a "DROP/DELETE/ALTER" query.
* Displays a confirmation box before submitting a "DROP/DELETE/ALTER" query.
* This function is called while clicking links
*
* @param object the link
@@ -1657,7 +1657,7 @@ $(document).ready(function() {
/**
* @var question String containing the question to be asked for confirmation
*/
var question = PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP DATABASE ' + window.parent.db;
var question = PMA_messages['strDropDatabaseStrongWarning'] + '\n' + PMA_messages['strDoYouReally'] + ' :\n' + 'DROP DATABASE ' + escapeHtml(window.parent.db);
$(this).PMA_confirm(question, $(this).attr('href') ,function(url) {
@@ -2287,3 +2287,14 @@ $(document).ready(function() {
}) // end of $(document).ready()
/**
* HTML escaping
*/
function escapeHtml(unsafe) {
return unsafe
.replace(/&/g, "&")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/"/g, "&quot;")
.replace(/'/g, "&#039;");
}