Commit baf8ead2 authored by Hanno Schlichting's avatar Hanno Schlichting

Merged r78365 from 2.10 branch.

parent ff82d86a
......@@ -132,6 +132,9 @@ Zope Changes
Bugs Fixed
- ZopePageTemplate's pt_edit did not recognize content type arguments
which had a charset information included.
- "version.txt" file was being written to the wrong place by the
Makefile, causing Zope to report "unreleased version" even for
released versions.
......
......@@ -126,7 +126,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
encoding = None
output_encoding = None
if content_type in ('text/xml',):
if content_type.startswith('text/xml'):
if is_unicode:
encoding = None
......@@ -134,9 +134,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
else:
encoding = encodingFromXMLPreamble(text)
output_encoding = 'utf-8'
elif content_type in ('text/html',) :
elif content_type.startswith('text/html'):
charset = charsetFromMetaEquiv(text)
......@@ -156,8 +155,8 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
output_encoding = 'iso-8859-15'
else:
utext, encoding = convertToUnicode(text,
content_type,
utext, encoding = convertToUnicode(text,
content_type,
preferred_encodings)
output_encoding = encoding
......
......@@ -165,6 +165,13 @@ class ZopePageTemplateFileTests(ZopeTestCase):
self.assertEqual(zpt.read(), s)
self.assertEqual(isinstance(zpt.read(), unicode), True)
def testEditWithContentTypeCharset(self):
manage_addPageTemplate(self.app, 'test', xml_utf8, encoding='utf-8')
zpt = self.app['test']
xml_unicode = unicode(xml_utf8, 'utf-8').strip()
zpt.pt_edit(xml_unicode, 'text/xml')
zpt.pt_edit(xml_unicode, 'text/xml; charset=utf-8')
self.assertEqual(zpt.read(), xml_unicode)
def _createZPT(self):
manage_addPageTemplate(self.app, 'test', text=utf8_str, encoding='utf-8')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment