[Zope-Checkins] CVS: Zope2 - PropertySheets.py:1.75
andreas@serenade.digicool.com
andreas@serenade.digicool.com
Thu, 5 Jul 2001 10:54:28 -0400
Update of /cvs-repository/Zope2/lib/python/OFS
In directory serenade:/tmp/cvs-serv25642
Modified Files:
PropertySheets.py
Log Message:
Backport of Webdav adjustments from 2.4 branch
--- Updated File PropertySheets.py in package Zope2 --
--- PropertySheets.py 2001/06/06 14:47:47 1.74
+++ PropertySheets.py 2001/07/05 14:54:28 1.75
@@ -375,7 +375,9 @@
else:
# Quote non-xml items here?
attrs=''
- prop=' <n:%s%s><![CDATA[%s]]></n:%s>' % (name, attrs, value, name)
+
+ prop=' <n:%s%s>%s</n:%s>' % (name, attrs, xml_escape(value), name)
+
result.append(prop)
if not result: return ''
result=join(result, '\n')
@@ -535,7 +537,7 @@
{'id':'supportedlock', 'mode':'r'},
{'id':'lockdiscovery', 'mode':'r'},
)
-
+
def getProperty(self, id, default=None):
method='dav__%s' % id
if not hasattr(self, method):
@@ -804,3 +806,16 @@
if callable(attr):
return attr()
return attr
+
+
+def xml_escape(v):
+ """ convert any content from ISO-8859-1 to UTF-8
+ The main use is to escape non-US object property values
+ (e.g. containing accented characters). Also we convert "<" and ">"
+ to entities to keep the properties XML compliant.
+ """
+
+ v = str(v).replace('<','<')
+ v = v.replace('>','>')
+
+ return unicode(v,"latin-1").encode("utf-8")