summaryrefslogtreecommitdiff
path: root/paste/util/quoting.py
diff options
context:
space:
mode:
Diffstat (limited to 'paste/util/quoting.py')
-rw-r--r--paste/util/quoting.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/paste/util/quoting.py b/paste/util/quoting.py
index d029518..5f42e6a 100644
--- a/paste/util/quoting.py
+++ b/paste/util/quoting.py
@@ -6,7 +6,8 @@ import htmlentitydefs
import urllib
import re
-__all__ = ['html_quote', 'html_unquote', 'url_quote', 'url_unquote']
+__all__ = ['html_quote', 'html_unquote', 'url_quote', 'url_unquote',
+ 'strip_html']
default_encoding = 'UTF-8'
@@ -59,6 +60,13 @@ def html_unquote(s, encoding=None):
s = s.decode(encoding or default_encoding)
return _unquote_re.sub(_entity_subber, s)
+def strip_html(s):
+ # should this use html_unquote?
+ s = re.sub('<.*?>', '', s)
+ s = s.replace('&nbsp;', ' ').replace('&lt;', '<')
+ s = s.replace('&gt;', '>').replace('&amp;','&')
+ return s
+
url_quote = urllib.quote
url_unquote = urllib.unquote