tools.web: don't try to striphtml content that is not str or buffer
This commit is contained in:
parent
9b2bc27374
commit
760da8ef61
1 changed files with 3 additions and 0 deletions
|
@ -208,6 +208,9 @@ def striphtml(data):
|
||||||
data -- the string to strip
|
data -- the string to strip
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if data is None or (not isinstance(data, str) and not isinstance(data, buffer)):
|
||||||
|
return data
|
||||||
|
|
||||||
import re
|
import re
|
||||||
p = re.compile(r'<.*?>')
|
p = re.compile(r'<.*?>')
|
||||||
r, _ = re.subn(r' +', ' ', htmlentitydecode(p.sub('', data)
|
r, _ = re.subn(r' +', ' ', htmlentitydecode(p.sub('', data)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue