comparison libervia/server/html_tools.py @ 1509:106bae41f5c8

massive refactoring from camelCase -> snake_case. See backend commit log for more details
author Goffi <goffi@goffi.org>
date Sat, 08 Apr 2023 13:44:11 +0200
parents 822bd0139769
children
comparison
equal deleted inserted replaced
1508:ec3ad9abf9f9 1509:106bae41f5c8
16 16
17 # You should have received a copy of the GNU Affero General Public License 17 # You should have received a copy of the GNU Affero General Public License
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 sanitize_html(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 "&": "&amp;", 25 "&": "&amp;",
26 '"': "&quot;", 26 '"': "&quot;",
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 convert_new_lines_to_xhtml(text):
36 return text.replace("\n", "<br/>") 36 return text.replace("\n", "<br/>")