Mercurial > libervia-web
comparison src/server/html_tools.py @ 1113:cdd389ef97bc
server: code style reformatting using black
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 29 Jun 2018 17:45:26 +0200 |
parents | f2170536ba23 |
children |
comparison
equal
deleted
inserted
replaced
1112:f287fc8bb31a | 1113:cdd389ef97bc |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 | 20 |
21 def sanitizeHtml(text): | 21 def sanitizeHtml(text): |
22 """Sanitize HTML by escaping everything""" | 22 """Sanitize HTML by escaping everything""" |
23 #this code comes from official python wiki: http://wiki.python.org/moin/EscapingHtml | 23 # this code comes from official python wiki: http://wiki.python.org/moin/EscapingHtml |
24 html_escape_table = { | 24 html_escape_table = { |
25 "&": "&", | 25 "&": "&", |
26 '"': """, | 26 '"': """, |
27 "'": "'", | 27 "'": "'", |
28 ">": ">", | 28 ">": ">", |
29 "<": "<", | 29 "<": "<", |
30 } | 30 } |
31 | 31 |
32 return "".join(html_escape_table.get(c, c) for c in text) | 32 return "".join(html_escape_table.get(c, c) for c in text) |
33 | 33 |
34 | 34 |
35 def convertNewLinesToXHTML(text): | 35 def convertNewLinesToXHTML(text): |
36 return text.replace('\n', '<br/>') | 36 return text.replace("\n", "<br/>") |