Merge branch 'QA_4_6'

This commit is contained in:
Michal Čihař 2016-08-27 09:16:08 +02:00
commit b4807f74e8
3 changed files with 23 additions and 9 deletions

View File

@ -41,6 +41,7 @@ phpMyAdmin - ChangeLog
- issue #12497 Missing escaping of configuration used in SQL (hide_db and only_db)
- issue #12476 Add error checking in reading advisory rules file
- issue #12477 Add checking missing elements and confirming element types from json_decode
- issue #12251 Automatically save SQL query in browser local storage rather than in cookie
4.6.4 (2016-08-16)
- issue [security] Weaknesses with cookie encryption, see PMASA-2016-29

View File

@ -1164,7 +1164,9 @@ function insertQuery(queryType)
}
return;
} else if (queryType == "saved") {
if ($.cookie('auto_saved_sql')) {
if (isStorageSupported('localStorage') && typeof window.localStorage.auto_saved_sql != 'undefined') {
setQuery(window.localStorage.auto_saved_sql);
} else if ($.cookie('auto_saved_sql')) {
setQuery($.cookie('auto_saved_sql'));
} else {
PMA_ajaxShowMessage(PMA_messages.strNoAutoSavedQuery);

View File

@ -36,6 +36,23 @@ function PMA_urlencode(str)
}
}
/**
* Saves SQL query in local storage or cooie
*
* @param string SQL query
* @return void
*/
function PMA_autosaveSQL(query)
{
if (query) {
if (isStorageSupported('localStorage')) {
window.localStorage.auto_saved_sql = query;
} else {
$.cookie('auto_saved_sql', query);
}
}
}
/**
* Get the field name for the current field. Required to construct the query
* for grid editing
@ -135,17 +152,11 @@ AJAX.registerOnload('sql.js', function () {
$(function () {
if (codemirror_editor) {
codemirror_editor.on('change', function () {
var query = codemirror_editor.getValue();
if (query) {
$.cookie('auto_saved_sql', query);
}
PMA_autosaveSQL(codemirror_editor.getValue());
});
} else {
$('#sqlquery').on('input propertychange', function () {
var query = $('#sqlquery').val();
if (query) {
$.cookie('auto_saved_sql', query);
}
PMA_autosaveSQL($('#sqlquery').val());
});
}
});