From eb2c5797cb756ea32a623a15e2e29878321d5316 Mon Sep 17 00:00:00 2001 From: Elijah Steres Date: Wed, 6 Jan 2021 14:14:19 -0500 Subject: [PATCH 1/2] Fix js injection vulnerability --- templates/game_box.html | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/templates/game_box.html b/templates/game_box.html index c4d1d1d..d94ac25 100644 --- a/templates/game_box.html +++ b/templates/game_box.html @@ -5,18 +5,18 @@ src={% if state.bases[number] %}"/static/img/base_filled.png" alt="{{state.bases {% if number <= state.outs %}/static/img/out_out.png{% else %}/static/img/out_in.png{% endif %} {%- endmacro %}
-
Inning: {% if state.display_top_of_inning == true %}🔼{% else %}🔽{% endif %} {{ state.display_inning }}/{{ state.max_innings }}
-
{{ state.title }}
-
{{ state.weather_emoji }} {{ state.weather_text }}
+
Inning: {% if state.display_top_of_inning == true %}🔼{% else %}🔽{% endif %} {{ state.display_inning | escape }}/{{ state.max_innings | escape }}
+
{{ state.title | escape }}
+
{{ state.weather_emoji | escape }} {{ state.weather_text | escape }}
-
{{ state.away_name }}
+
{{ state.away_name | escape }}
{{ state.away_score }}
-
{{ state.home_name }}
+
{{ state.home_name | escape }}
{{ state.home_score }}
@@ -38,16 +38,16 @@ src={% if state.bases[number] %}"/static/img/base_filled.png" alt="{{state.bases
PITCHER
-
{{ state.pitcher }}
+
{{ state.pitcher | escape }}
BATTER
-
{{ state.batter }}
+
{{ state.batter | escape }}
-
{{ state.update_emoji }}
-
{{ state.update_text }}
+
{{ state.update_emoji | escape }}
+
{{ state.update_text | escape }}
\ No newline at end of file From c931733ad17f15363bd1bbb48911fc0a87bf5833 Mon Sep 17 00:00:00 2001 From: Elijah Steres Date: Wed, 6 Jan 2021 15:20:46 -0500 Subject: [PATCH 2/2] forgot about leagues, whoops --- static/js/grid_loader.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/static/js/grid_loader.js b/static/js/grid_loader.js index f203bd7..39ba154 100644 --- a/static/js/grid_loader.js +++ b/static/js/grid_loader.js @@ -88,11 +88,20 @@ const insertGame = (gridboxnum, game) => { const insertLeague = (league) => { var btn = document.createElement("BUTTON"); btn.className = "filter"; - btn.innerHTML = league; + btn.innerHTML = escapeHtml(league); $('#filters').append(btn); return btn; } +function escapeHtml(unsafe) { + return unsafe + .replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); + } + const clearBox = (box) => { box.className = "emptyslot"; box.timestamp = null;