diff --git a/coinmanager/coinc/static/coinc/main.js b/coinmanager/coinc/static/coinc/main.js index 5ccf1cb..5c6e026 100644 --- a/coinmanager/coinc/static/coinc/main.js +++ b/coinmanager/coinc/static/coinc/main.js @@ -31,11 +31,29 @@ let settings = { exists: true } + // // Functions // -// return a datetime YYYY.MM.DD +/* return escaped html */ +function escape_html (string) { + let entity_map = { + '&': '&', + '<': '<', + '>': '>', + '"': '"', + "'": ''', + '/': '/', + '`': '`', + '=': '=' + }; + return String(string).replace(/[&<>"'`=\/]/g, function (s) { + return entity_map[s]; + }); +} + +/* return a datetime YYYY.MM.DD */ function get_datetime() { let datetime = new Date(); return ('0' + datetime.getDate()).slice(-2) + '.' + @@ -132,12 +150,13 @@ function render_response(data, td, set) { /* add/update name */ if ('name' in data) { + let name = escape_html(data['name']); let c = String(value).substring(2,3); let div_special_name = $(td).find('div.special' + c + '_name'); if (div_special_name.length == 0) { - $(td).append('