appy.gen: bugfix while searching the catalog based on object state; added XHTML cleanup code; added String.generatePassword; bugfix: mising HTTP header while sending some responses back to Apache (caused a bug in ckeditor image upload); bugfix while importing images via an image resolver (Zope behind a reverse proxy).

This commit is contained in:
Gaetan Delannay 2012-04-25 16:21:23 +02:00
parent d52e601ea8
commit 9b8064b0cd
5 changed files with 26 additions and 8 deletions

View file

@ -268,13 +268,15 @@ xhtmlClassAttr = re.compile('class\s*=\s*".*?"')
xhtmlStyleAttr = re.compile('style\s*=\s*".*?"')
xhtmlComment = re.compile('<!--.*?-->', re.S)
def cleanXhtml(s):
def cleanXhtml(s, keepStyles=False):
'''Returns a version of XHTML string p_s where:
* attributes "class" and "style" have been removed;
* attributes "class" and "style" have been removed (only if p_keepStyles
is False);
* XHTML comments have been removed.
'''
s = xhtmlClassAttr.sub('', s)
s = xhtmlStyleAttr.sub('', s)
if not keepStyles:
s = xhtmlClassAttr.sub('', s)
s = xhtmlStyleAttr.sub('', s)
s = xhtmlComment.sub('', s)
return s