idolezal commited on
Commit
f3684c5
1 Parent(s): a1ddac4

HTML escape

Browse files
Files changed (1) hide show
  1. server.py +2 -1
server.py CHANGED
@@ -5,6 +5,7 @@ import os
5
  import hashlib
6
  import time
7
  from collections import namedtuple
 
8
 
9
  import gradio as gr
10
  import pandas as pd
@@ -110,7 +111,7 @@ class LeaderboardServer:
110
  model_link = data["metadata"]["link_to_model"]
111
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
112
  model_title_abbr = self.abbreviate(data["metadata"]["team_name"], 14) + "/" + self.abbreviate(data["metadata"]["model_name"], 14)
113
- local_results["model"] = f'<a href="{model_link}" title="{model_title}">{model_title_abbr}</a>' # TODO: HTML escape
114
  release = data["metadata"].get("submission_timestamp")
115
  release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
116
  local_results["release"] = release
 
5
  import hashlib
6
  import time
7
  from collections import namedtuple
8
+ from xml.sax.saxutils import escape as xmlEscape, quoteattr as xmlQuoteAttr
9
 
10
  import gradio as gr
11
  import pandas as pd
 
111
  model_link = data["metadata"]["link_to_model"]
112
  model_title = data["metadata"]["team_name"] + "/" + data["metadata"]["model_name"]
113
  model_title_abbr = self.abbreviate(data["metadata"]["team_name"], 14) + "/" + self.abbreviate(data["metadata"]["model_name"], 14)
114
+ local_results["model"] = f'<a href={xmlQuoteAttr(model_link)} title={xmlQuoteAttr(model_title)}>{xmlEscape(model_title_abbr)}</a>' # TODO: Markdown esacape
115
  release = data["metadata"].get("submission_timestamp")
116
  release = time.strftime("%Y-%m-%d", time.gmtime(release)) if release else "N/A"
117
  local_results["release"] = release