Mercurial > libervia-web
comparison browser_side/html_tools.py @ 370:30d03d9f07e4
browser_side: refactorization of the file tools.py:
- tools.py renamed to html_tools.py
- method setPresenceStyle moved to contact.py
- classes DragLabel and LiberviaDragWidget moved to base_widget.py
- class FilterFileUpload moved to file_tools.py
author | souliane <souliane@mailoo.org> |
---|---|
date | Sun, 23 Feb 2014 17:01:03 +0100 |
parents | browser_side/tools.py@187126b63170 |
children | 41b8b96f2248 |
comparison
equal
deleted
inserted
replaced
369:678d1739bbf2 | 370:30d03d9f07e4 |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 | |
4 # Libervia: a Salut à Toi frontend | |
5 # Copyright (C) 2011, 2012, 2013, 2014 Jérôme Poisson <goffi@goffi.org> | |
6 | |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
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/>. | |
19 | |
20 from nativedom import NativeDOM | |
21 from sat_frontends.tools import xmltools | |
22 import re | |
23 | |
24 dom = NativeDOM() | |
25 | |
26 | |
27 def html_sanitize(html): | |
28 """Naive sanitization of HTML""" | |
29 return html.replace('<', '<').replace('>', '>') | |
30 | |
31 | |
32 def html_strip(html): | |
33 """Strip leading/trailing white spaces, HTML line breaks and sequences.""" | |
34 cleaned = re.sub(r"^(<br/?>| |\s)+", "", html) | |
35 cleaned = re.sub(r"(<br/?>| |\s)+$", "", cleaned) | |
36 return cleaned | |
37 | |
38 | |
39 def inlineRoot(xhtml): | |
40 """ make root element inline """ | |
41 doc = dom.parseString(xhtml) | |
42 return xmltools.inlineRoot(doc) |