From 94b8de9d78fa8c7ec007ebedd88fa6002a140910 Mon Sep 17 00:00:00 2001 From: Ac_K Date: Thu, 27 Aug 2020 23:21:22 +0200 Subject: [PATCH] Fix html/js escaping --- main.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.js b/main.js index 77cd25d..3babb85 100644 --- a/main.js +++ b/main.js @@ -1,4 +1,6 @@ $(document).ready(function() { + function encode(r){return r.replace(/[\x26\x0A\<>'"]/g,function(r){return"&#"+r.charCodeAt(0)+";"})} + $.getJSON("/api", function(data) { $(".main-stats").append('
Public Players
' + data.public_players_count + '
'); $(".main-stats").append('
Private Players
' + data.private_players_count + '
'); @@ -14,7 +16,7 @@ $(document).ready(function() { $.getJSON("/api/public_games", function(data) { $.each(data, function() { - $(".games-table").append(' ' + this.game_name + '
(' + this.title_id + ')' + this.player_count + '/' + this.max_player_count + '
' + this.players.join(', ') + ' ' + this.mode + ' (' + this.status + ')'); + $(".games-table").append(' ' + this.game_name + '
(' + this.title_id + ')' + this.player_count + '/' + this.max_player_count + '
' + encode(this.players.join(', ')) + ' ' + this.mode + ' (' + this.status + ')'); }); }); }); \ No newline at end of file