[kupu-checkins] r43894 - kupu/trunk/kupu/plone
duncan at codespeak.net
duncan at codespeak.net
Wed May 30 13:26:20 CEST 2007
Author: duncan
Date: Wed May 30 13:26:19 2007
New Revision: 43894
Modified:
kupu/trunk/kupu/plone/plonedrawers.py
Log:
Fix problem arising because some content can return unicode Title and unicode.translate is not compatible with str.translate.
Modified: kupu/trunk/kupu/plone/plonedrawers.py
==============================================================================
--- kupu/trunk/kupu/plone/plonedrawers.py (original)
+++ kupu/trunk/kupu/plone/plonedrawers.py Wed May 30 13:26:19 2007
@@ -41,6 +41,13 @@
UIDURL = re.compile(".*\\bresolveuid/([^/?#]+)")
NOCC = nocc = string.maketrans(''.join([chr(c) for c in range(32) if c not in (9,10,13)]), "?"*29)
+uNOCC = dict([(c,ord('?')) for c in range(32) if c not in (9,10,13)])
+def filterControlChars(s):
+ """convert characters which are illegal in xml to '?'"""
+ if isinstance(s, unicode):
+ return s.translate(uNOCC)
+ else:
+ return s.translate(NOCC)
# mapping (thread-id, portal-physicalPath, portal_type) ->
# imagefield-getAvailableSizes (as tuple sorted by dimension) (width, height, key)
@@ -346,7 +353,7 @@
icon = self.icon(portal_type)
size, width, height = self.sizes(obj)
- title = (obj.Title() or obj.getId()).translate(NOCC)
+ title = filterControlChars(obj.Title() or obj.getId())
description = newline_to_br(html_quote(obj.Description()))
linkable = None
@@ -427,7 +434,7 @@
icon = self.icon(portal_type)
size, width, height = self.sizes(brain)
- title = (brain.Title or brain.getId).translate(NOCC)
+ title = filterControlChars(brain.Title or brain.getId)
description = newline_to_br(html_quote(brain.Description))
linkable = None
if allowLink:
More information about the kupu-checkins
mailing list