Commit 124cdb8b authored by Hanno Schlichting's avatar Hanno Schlichting

Changed the value for `default-zpublisher-encoding` and `management_page_charset` to `utf-8`.

parent c2dba5e7
......@@ -31,6 +31,9 @@ Features Added
Restructuring
+++++++++++++
- Changed the value for `default-zpublisher-encoding` and
`management_page_charset` to `utf-8`.
- Removed the `enable-ms-author-via` directive which was only required for
very old web folder implementations from before 2007.
......
......@@ -791,7 +791,6 @@ def xml_escape(value):
if not isinstance(value, basestring):
value = unicode(value)
if not isinstance(value, unicode):
# XXX It really shouldn't be hardcoded to latin-1 here.
value = value.decode('latin-1')
value = value.decode('utf-8')
value = escape(value)
return value.encode('utf-8')
......@@ -14,7 +14,6 @@
"""
import os
import re
from AccessControl.class_init import InitializeClass
from AccessControl.Permissions import change_page_templates
......@@ -23,7 +22,6 @@ from AccessControl.Permissions import view
from AccessControl.Permissions import view_management_screens
from AccessControl.SecurityManagement import getSecurityManager
from AccessControl.SecurityInfo import ClassSecurityInfo
from AccessControl.ZopeGuards import safe_builtins
from Acquisition import Acquired
from Acquisition import Explicit
from Acquisition import aq_get
......@@ -51,7 +49,6 @@ from Products.PageTemplates.utils import convertToUnicode
preferred_encodings = ['utf-8', 'iso-8859-15']
if os.environ.has_key('ZPT_PREFERRED_ENCODING'):
preferred_encodings.insert(0, os.environ['ZPT_PREFERRED_ENCODING'])
class Src(Explicit):
......@@ -73,7 +70,7 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
"Zope wrapper for Page Template using TAL, TALES, and METAL"
meta_type = 'Page Template'
output_encoding = 'iso-8859-15' # provide default for old instances
output_encoding = 'utf-8' # provide default for old instances
func_defaults = None
func_code = FuncCode((), 0)
......@@ -147,14 +144,14 @@ class ZopePageTemplate(Script, PageTemplate, Historical, Cacheable,
output_encoding = charset
else:
encoding = None
output_encoding = 'iso-8859-15'
output_encoding = 'utf-8'
else:
if charset:
encoding = charset
output_encoding = charset
else:
encoding = 'iso-8859-15'
output_encoding = 'iso-8859-15'
encoding = 'utf-8'
output_encoding = 'utf-8'
else:
utext, encoding = convertToUnicode(text,
......
# *-* coding: iso-8859-15 -*-
# *-* coding: iso-8859-1 -*-
import unittest
......@@ -26,7 +26,7 @@ class EngineTestsBase(PlacelessSetup):
def __call__(self):
return 'dummy'
management_page_charset = 'iso-8859-15'
management_page_charset = 'utf-8'
class DummyDocumentTemplate:
__allow_access_to_unprotected_subobjects__ = 1
......@@ -184,8 +184,8 @@ class EngineTestsBase(PlacelessSetup):
import StrictUnicodeEncodingConflictResolver
from Products.PageTemplates.interfaces \
import IUnicodeEncodingConflictResolver
provideUtility(StrictUnicodeEncodingConflictResolver,
IUnicodeEncodingConflictResolver)
provideUtility(StrictUnicodeEncodingConflictResolver,
IUnicodeEncodingConflictResolver)
self.assertEqual(ec.evaluate(expr), u'')
class UntrustedEngineTests(EngineTestsBase, unittest.TestCase):
......@@ -229,8 +229,8 @@ class UnicodeEncodingConflictResolverTests(PlacelessSetup, unittest.TestCase):
provideUtility(StrictUnicodeEncodingConflictResolver,
IUnicodeEncodingConflictResolver)
resolver = getUtility(IUnicodeEncodingConflictResolver)
self.assertRaises(UnicodeDecodeError,
resolver.resolve, None, '', None)
text = u'\xe4\xfc\xe4'
self.assertEqual(resolver.resolve(None, text, None), text)
def testIgnoringResolver(self):
from zope.component import getUtility
......
......@@ -13,7 +13,7 @@ import Zope2
import transaction
import zope.component.testing
from zope.traversing.adapters import DefaultTraversable, Traverser
from zope.traversing.adapters import DefaultTraversable
from zope.publisher.http import HTTPCharsets
from Testing.makerequest import makerequest
......@@ -200,7 +200,7 @@ class ZPTUnicodeEncodingConflictResolution(ZopeTestCase):
output_encoding='ascii',
)
state = cPickle.dumps(empty, protocol=1)
clone = cPickle.loads(state)
cPickle.loads(state)
def testBug246983(self):
# See https://bugs.launchpad.net/bugs/246983
......@@ -250,7 +250,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
result = zpt.pt_render()
# use startswith() because the renderer appends a trailing \n
self.assertEqual(result.encode('ascii').startswith(ascii_str), True)
self.assertEqual(zpt.output_encoding, 'iso-8859-15')
self.assertEqual(zpt.output_encoding, 'utf-8')
def testPT_RenderUnicodeExpr(self):
# Check workaround for unicode incompatibility of ZRPythonExpr.
......@@ -260,7 +260,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
'unicode(\'\xfe\', \'iso-8859-15\')" />'),
encoding='iso-8859-15')
zpt = self.app['test']
result = zpt.pt_render() # should not raise a UnicodeDecodeError
zpt.pt_render() # should not raise a UnicodeDecodeError
def testPT_RenderWithISO885915(self):
manage_addPageTemplate(self.app, 'test',
......@@ -270,7 +270,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
# use startswith() because the renderer appends a trailing \n
self.assertTrue(result.encode('iso-8859-15'
).startswith(iso885915_str))
self.assertEqual(zpt.output_encoding, 'iso-8859-15')
self.assertEqual(zpt.output_encoding, 'utf-8')
def testPT_RenderWithUTF8(self):
manage_addPageTemplate(self.app, 'test',
......@@ -279,7 +279,7 @@ class ZopePageTemplateFileTests(ZopeTestCase):
result = zpt.pt_render()
# use startswith() because the renderer appends a trailing \n
self.assertEqual(result.encode('utf-8').startswith(utf8_str), True)
self.assertEqual(zpt.output_encoding, 'iso-8859-15')
self.assertEqual(zpt.output_encoding, 'utf-8')
def testWriteAcceptsUnicode(self):
manage_addPageTemplate(self.app, 'test', '', encoding='utf-8')
......@@ -323,14 +323,9 @@ class ZopePageTemplateFileTests(ZopeTestCase):
self.assertEqual(zpt.output_encoding, 'utf-8')
self.assertEqual(zpt.content_type, 'text/html')
def testPutHTMLIso8859_15WithoutCharsetInfo(self):
zpt = self._put(html_iso_8859_15_wo_header)
self.assertEqual(zpt.output_encoding, 'iso-8859-15')
self.assertEqual(zpt.content_type, 'text/html')
def testPutHTMLUTF8_WithoutCharsetInfo(self):
zpt = self._put(html_utf8_wo_header)
self.assertEqual(zpt.output_encoding, 'iso-8859-15')
self.assertEqual(zpt.output_encoding, 'utf-8')
self.assertEqual(zpt.content_type, 'text/html')
def testPutXMLIso8859_15(self):
......@@ -338,20 +333,20 @@ class ZopePageTemplateFileTests(ZopeTestCase):
zpt = self._put(xml_iso_8859_15)
self.assertEqual(zpt.output_encoding, 'utf-8')
self.assertEqual(zpt.content_type, 'text/xml')
result = zpt.pt_render() # should not raise an exception
zpt.pt_render() # should not raise an exception
def testPutXMLUTF8(self):
""" XML: use always UTF-8 als output encoding """
zpt = self._put(xml_utf8)
self.assertEqual(zpt.output_encoding, 'utf-8')
self.assertEqual(zpt.content_type, 'text/xml')
result = zpt.pt_render() # should not raise an exception
zpt.pt_render() # should not raise an exception
def testXMLAttrsMustNotBeLowercased(self):
zpt = self._put(xml_with_upper_attr)
self.assertEqual(zpt.content_type, 'text/xml')
result = zpt.pt_render()
self.assertEqual('ATTR' in result, True)
self.assertEqual('ATTR' in result, True)
def testHTMLAttrsAreLowerCased(self):
zpt = self._put(html_with_upper_attr)
......@@ -372,9 +367,9 @@ class PreferredCharsetUnicodeResolverTests(unittest.TestCase):
# This test checks the edgecase where the unicode conflict resolver
# is called with a context object having no REQUEST
class ContextMock:
management_page_charset = 'iso-8859-15'
management_page_charset = 'utf-8'
result = PreferredCharsetResolver.resolve(ContextMock(), '', None)
self.assertEqual(result, u'')
self.assertEqual(result, '')
class ZPTRegressions(unittest.TestCase):
......
......@@ -54,7 +54,11 @@ class Z2UnicodeEncodingConflictResolver:
return unicode(text)
except UnicodeDecodeError:
encoding = getattr(context, 'management_page_charset', default_encoding)
return unicode(text, encoding, self.mode)
try:
return unicode(text, encoding, self.mode)
except UnicodeDecodeError:
# finally try the old management_page_charset default
return unicode(text, 'iso-8859-15', self.mode)
class PreferredCharsetResolver:
......
. charset configuration, defaulting to 'latin-1'
. add "level" and "header" args to render / as_html
- level indicates the header level to start at
- header boolean turns page header tags on/off
......@@ -73,8 +73,8 @@ class ZReST(Item, PropertyManager, Historical, Implicit, Persistent):
{'id':'stylesheet', 'type': 'string', 'mode': 'w',
'default': ''},
{'id':'report_level', 'type': 'string', 'mode': 'w', 'default': '2'},
{'id':'input_encoding', 'type': 'string', 'mode': 'w', 'default': 'iso-8859-15'},
{'id':'output_encoding', 'type': 'string', 'mode': 'w', 'default': 'iso-8859-15'},
{'id':'input_encoding', 'type': 'string', 'mode': 'w', 'default': 'utf-8'},
{'id':'output_encoding', 'type': 'string', 'mode': 'w', 'default': 'utf-8'},
)
property_extensible_schema__ = 0
......
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
""" Unit tests for ZReST objects
"""
......@@ -12,7 +12,7 @@ txt = """Hello World
text text
Von Vgeln und fen
Von V\xc3\xb6geln und \xc3\x96fen
===================
- some
......@@ -62,15 +62,15 @@ class TestZReST(unittest.TestCase):
def testConversion(self):
resty = self._makeOne()
resty.source = txt
resty.input_encoding = 'iso-8859-15'
resty.output_encoding = 'iso-8859-15'
resty.input_encoding = 'utf-8'
resty.output_encoding = 'utf-8'
resty.render()
html = resty.index_html()
s = '<h1>Hello World</h1>'
self.assertEqual(s in html, True)
s = '<h1>Von Vgeln und fen</h1>'
s = '<h1>Von V\xc3\xb6geln und \xc3\x96fen</h1>'
self.assertEqual(s in html, True)
# ZReST should render a complete HTML document
......
......@@ -86,7 +86,7 @@ Test parameter containing an additional '?'
... """)
HTTP/1.1 200 OK
Content-Length: 5
Content-Type: text/plain; charset=iso-8859-15
Content-Type: text/plain; charset=utf-8
<BLANKLINE>
index
......
......@@ -18,7 +18,7 @@ from DateTime.interfaces import SyntaxError
from cgi import escape
# This may get overwritten during configuration
default_encoding = 'iso-8859-15'
default_encoding = 'utf-8'
def field2string(v):
if hasattr(v,'read'): return v.read()
......
......@@ -56,7 +56,7 @@ xmlrpc = None
base64 = None
# This may get overwritten during configuration
default_encoding = 'iso-8859-15'
default_encoding = 'utf-8'
isCGI_NAMEs = {
'SERVER_SOFTWARE' : 1,
......@@ -642,7 +642,7 @@ class HTTPRequest(BaseRequest):
# We have a string with a specified character
# encoding. This gets passed to the converter
# either as unicode, if it can handle it, or
# crunched back down to latin-1 if it can not.
# crunched back down to utf-8 if it can not.
item = unicode(item,character_encoding)
if hasattr(converter,'convert_unicode'):
item = converter.convert_unicode(item)
......
......@@ -36,7 +36,7 @@ from ZPublisher.pubevents import PubBeforeStreaming
nl2sp = maketrans('\n', ' ')
# This may get overwritten during configuration
default_encoding = 'iso-8859-15'
default_encoding = 'utf-8'
# Enable APPEND_TRACEBACKS to make Zope append tracebacks like it used to,
# but a better solution is to make standard_error_message display error_tb.
......
......@@ -158,7 +158,7 @@ And the same with unicode error value.
HTTPError: HTTP Error 401: Unauthorized
>>> 'Error Type: Unauthorized' in browser.contents
True
>>> 'Error Value: ERROR VALUE ?' in browser.contents
>>> 'Error Value: ERROR VALUE \xce\xa9' in browser.contents
True
>>> browser.headers['WWW-Authenticate']
'basic realm="Zope2"'
......
......@@ -205,7 +205,6 @@ class HTTPRequestTests(unittest.TestCase):
('utext:utext:utf8', 'test\xc2\xae\ntest\xc2\xae\n'),
('utokens:utokens:utf8', 'test\xc2\xae test\xc2\xae'),
('ulines:ulines:utf8', 'test\xc2\xae\ntest\xc2\xae'),
('nouconverter:string:utf8', 'test\xc2\xae'))
req = self._processInputs(inputs)
......@@ -219,8 +218,8 @@ class HTTPRequestTests(unittest.TestCase):
self.assertEquals(req['utokens'], [u'test\u00AE', u'test\u00AE'])
self.assertEquals(req['ulines'], [u'test\u00AE', u'test\u00AE'])
# expect a latin1 encoded version
self.assertEquals(req['nouconverter'], 'test\xae')
# expect a utf-8 encoded version
self.assertEquals(req['nouconverter'], 'test\xc2\xae')
self._noTaintedValues(req)
self._onlyTaintedformHoldsTaintedStrings(req)
......
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
import unittest
import sys
......@@ -68,13 +68,13 @@ class HTTPResponseTests(unittest.TestCase):
def test_ctor_charset_no_content_type_header(self):
response = self._makeOne(body='foo')
self.assertEqual(response.headers.get('content-type'),
'text/plain; charset=iso-8859-15')
'text/plain; charset=utf-8')
def test_ctor_charset_text_header_no_charset_defaults_latin1(self):
response = self._makeOne(body='foo',
headers={'content-type': 'text/plain'})
self.assertEqual(response.headers.get('content-type'),
'text/plain; charset=iso-8859-15')
'text/plain; charset=utf-8')
def test_ctor_charset_application_header_no_header(self):
response = self._makeOne(body='foo',
......@@ -90,15 +90,15 @@ class HTTPResponseTests(unittest.TestCase):
'application/foo; charset: something')
def test_ctor_charset_unicode_body_application_header(self):
BODY = unicode('rger', 'iso-8859-15')
BODY = u'\xe4rger'
response = self._makeOne(body=BODY,
headers={'content-type': 'application/foo'})
self.assertEqual(response.headers.get('content-type'),
'application/foo; charset=iso-8859-15')
self.assertEqual(response.body, 'rger')
'application/foo; charset=utf-8')
self.assertEqual(response.body, BODY.encode('utf-8'))
def test_ctor_charset_unicode_body_application_header_diff_encoding(self):
BODY = unicode('rger', 'iso-8859-15')
BODY = u'\xe4rger'
response = self._makeOne(body=BODY,
headers={'content-type':
'application/foo; charset=utf-8'})
......@@ -562,7 +562,7 @@ class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, EXPECTED)
self.assertEqual(response.getHeader('Content-Type'),
'text/html; charset=iso-8859-15')
'text/html; charset=utf-8')
self.assertEqual(response.getHeader('Content-Length'),
str(len(EXPECTED)))
......@@ -576,7 +576,7 @@ class HTTPResponseTests(unittest.TestCase):
self.assertTrue('TITLE' in response.body)
self.assertTrue('BODY' in response.body)
self.assertEqual(response.getHeader('Content-Type'),
'text/html; charset=iso-8859-15')
'text/html; charset=utf-8')
def test_setBody_string_not_HTML(self):
response = self._makeOne()
......@@ -584,7 +584,7 @@ class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, 'BODY')
self.assertEqual(response.getHeader('Content-Type'),
'text/plain; charset=iso-8859-15')
'text/plain; charset=utf-8')
self.assertEqual(response.getHeader('Content-Length'), '4')
def test_setBody_string_HTML(self):
......@@ -594,7 +594,7 @@ class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, HTML)
self.assertEqual(response.getHeader('Content-Type'),
'text/html; charset=iso-8859-15')
'text/html; charset=utf-8')
self.assertEqual(response.getHeader('Content-Length'), str(len(HTML)))
def test_setBody_object_with_asHTML(self):
......@@ -607,18 +607,18 @@ class HTTPResponseTests(unittest.TestCase):
self.assertTrue(result)
self.assertEqual(response.body, HTML)
self.assertEqual(response.getHeader('Content-Type'),
'text/html; charset=iso-8859-15')
'text/html; charset=utf-8')
self.assertEqual(response.getHeader('Content-Length'), str(len(HTML)))
def test_setBody_object_with_unicode(self):
HTML = u'<html><head></head><body><h1>Tr\u0039s Bien</h1></body></html>'
ENCODED = HTML.encode('iso-8859-15')
ENCODED = HTML.encode('utf-8')
response = self._makeOne()
result = response.setBody(HTML)
self.assertTrue(result)
self.assertEqual(response.body, ENCODED)
self.assertEqual(response.getHeader('Content-Type'),
'text/html; charset=iso-8859-15')
'text/html; charset=utf-8')
self.assertEqual(response.getHeader('Content-Length'),
str(len(ENCODED)))
......@@ -737,7 +737,7 @@ class HTTPResponseTests(unittest.TestCase):
def test_redirect_explicit_status(self):
URL = 'http://example.com'
response = self._makeOne()
result = response.redirect(URL, status=307)
response.redirect(URL, status=307)
self.assertEqual(response.status, 307)
self.assertEqual(response.getHeader('Location'), URL)
self.assertFalse(response._locked_status)
......@@ -745,7 +745,7 @@ class HTTPResponseTests(unittest.TestCase):
def test_redirect_w_lock(self):
URL = 'http://example.com'
response = self._makeOne()
result = response.redirect(URL, lock=True)
response.redirect(URL, lock=True)
self.assertEqual(response.status, 302)
self.assertEqual(response.getHeader('Location'), URL)
self.assertTrue(response._locked_status)
......@@ -1100,7 +1100,7 @@ class HTTPResponseTests(unittest.TestCase):
[('X-Powered-By', 'Zope (www.zope.org), '
'Python (www.python.org)'),
('Content-Length', '4'),
('Content-Type', 'text/plain; charset=iso-8859-15'),
('Content-Type', 'text/plain; charset=utf-8'),
])
def test___str__already_wrote(self):
......@@ -1251,7 +1251,7 @@ class HTTPResponseTests(unittest.TestCase):
'Python (www.python.org)')
self.assertEqual(lines[2], 'Content-Length: 4')
self.assertEqual(lines[3],
'Content-Type: text/plain; charset=iso-8859-15')
'Content-Type: text/plain; charset=utf-8')
self.assertEqual(lines[4], '')
self.assertEqual(lines[5], 'BLAH')
......
......@@ -24,7 +24,7 @@ class ConvertersTests(unittest.TestCase):
from ZPublisher.Converters import field2string
to_convert = u'to_convert'
self.assertEqual(field2string(to_convert),
to_convert.encode('iso-8859-15'))
to_convert.encode('utf-8'))
def test_field2string_with_filelike_object(self):
from ZPublisher.Converters import field2string
......
......@@ -152,7 +152,7 @@ class ZopeStarter:
# workaround to allow unicode encoding conversions in DTML
import codecs
dummy = codecs.lookup('iso-8859-1')
dummy = codecs.lookup('utf-8')
locale_id = self.cfg.locale
......
......@@ -202,13 +202,13 @@ class StartupTestCase(unittest.TestCase):
conf, dummy = self.load_config_text("""\
instancehome <<INSTANCE_HOME>>
""")
self.assertEqual(conf.default_zpublisher_encoding, 'iso-8859-15')
self.assertEqual(conf.default_zpublisher_encoding, 'utf-8')
conf, dummy = self.load_config_text("""\
instancehome <<INSTANCE_HOME>>
default-zpublisher-encoding utf-8
default-zpublisher-encoding iso-8859-15
""")
self.assertEqual(conf.default_zpublisher_encoding, 'utf-8')
self.assertEqual(conf.default_zpublisher_encoding, 'iso-8859-15')
def test_suite():
......
......@@ -841,7 +841,7 @@
<key name="default-zpublisher-encoding"
datatype=".default_zpublisher_encoding"
default="iso-8859-15">
default="utf-8">
<description>
This key controls what character set is used to encode unicode
data that reaches ZPublisher without any other specified encoding.
......
......@@ -355,104 +355,6 @@ instancehome $INSTANCE
# verbose-security on
# Directive: maximum-number-of-session-objects
#
# Description:
# An integer value representing the number of items to use as a
# "maximum number of subobjects" value of the
# '/temp_folder/session_data' transient object container.
#
# Default: 1000
#
# Example:
#
# maximum-number-of-session-objects 10000
# Directive: session-add-notify-script-path
#
# Description:
# An optional fill Zope path name of a callable object to be set as the
# "script to call on object addition" of the sessioN_data transient
# object container created in the /temp_folder folder at startup.
#
# Default: unset
#
# Example:
#
# session-add-notify-script-path /scripts/add_notifier
# Directive: session-delete-notify-script-path
#
# Description:
# An optional fill Zope path name of a callable object to be set as the
# "script to call on object deletion" of the sessioN_data transient
# object container created in the /temp_folder folder at startup.
#
# Default: unset
#
# Example:
#
# session-delete-notify-script-path /scripts/del_notifier
# Directive: session-timeout-minutes
#
# Description:
# An integer value representing the number of minutes to be used as the
# "data object timeout" of the '/temp_folder/session_data' transient
# object container.
#
# Default: 20
#
# Example:
#
# session-timeout-minutes 30
# Directive: session-resolution-seconds
#
# Description:
# An integer value representing the number of seconds to be used as the
# "timeout resolution" of the '/temp_folder/session_data' transient
# object container.
#
# Default: 20
#
# Example:
#
# session-resolution-seconds 60
# Directive: suppress-all-access-rules
#
# Description:
# If this directive is set to on, no access rules in your Zope site
# will be executed. This is useful if you "lock yourself out" of a
# particular part of your site by setting an improper access rule.
#
# Default: off
#
# Example:
#
# suppress-all-access-rules on
# Directive: suppress-all-site-roots
#
# Description:
# If this directive is set to on, no site roots in your Zope site will
# be effective. This is useful if you "lock yourself out" of a
# particular part of your site by setting an improper site root.
#
# Default: off
#
# Example:
#
# suppress-all-site-roots on
# Directives: logger
#
# Description:
......@@ -627,17 +529,6 @@ instancehome $INSTANCE
#
# large-file-threshold 1Mb
# Directive: default-zpublisher-encoding
#
# Description:
# This controls what character set is used to encode unicode
# data that reaches ZPublisher without any other specified encoding.
#
# Default: iso-8859-15
#
# Example:
#
# default-zpublisher-encoding utf-8
# Directives: servers
#
......
# -*- coding: iso-8859-15 -*-
# -*- coding: utf-8 -*-
import unittest
import cgi
......@@ -11,7 +11,7 @@ txt = """Hello World
text text
Von Vgeln und fen
Von V\xc3\xb6geln und \xc3\x96fen
===================
- some
......@@ -43,26 +43,25 @@ class TestReST(unittest.TestCase):
input_encoding=in_enc,
output_encoding=out_enc)
encoding = 'iso-8859-15'
encoding = 'utf-8'
html = _test(txt, encoding, encoding)
self.assertEqual('Vgel' in html, True)
self.assertEqual('fen' in html, True)
self.assertEqual('V\xc3\xb6gel' in html, True)
self.assertEqual('\xc3\x96fen' in html, True)
html = _test(txt, encoding, 'unicode')
self.assertEqual(unicode('Vgel', encoding) in html, True)
self.assertEqual(unicode('fen', encoding) in html, True)
self.assertEqual(unicode('V\xc3\xb6gel', encoding) in html, True)
self.assertEqual(unicode('\xc3\x96fen', encoding) in html, True)
html = _test(unicode(txt, encoding), 'unicode', encoding)
self.assertEqual('Vgel' in html, True)
self.assertEqual('fen' in html, True)
self.assertEqual('V\xc3\xb6gel' in html, True)
self.assertEqual('\xc3\x96fen' in html, True)
html = _test(unicode(txt, encoding), 'unicode', 'unicode')
self.assertEqual(unicode('Vgel', encoding) in html, True)
self.assertEqual(unicode('fen', encoding) in html, True)
self.assertEqual(unicode('V\xc3\xb6gel', encoding) in html, True)
self.assertEqual(unicode('\xc3\x96fen', encoding) in html, True)
def testHeaderLevel(self):
encoding = 'iso-8859-15'
encoding = 'utf-8'
for level in range(0, 5):
html = HTML(txt, input_encoding=encoding,
output_encoding=encoding,
......@@ -71,7 +70,8 @@ class TestReST(unittest.TestCase):
expected = '<h%d>Hello World</h%d>' % (level+1, level+1)
self.assertEqual(expected in html, True)
expected = '<h%d>Von Vgeln und fen</h%d>' % (level+1, level+1)
expected = '<h%d>Von V\xc3\xb6geln und \xc3\x96fen</h%d>' % (
level+1, level+1)
self.assertEqual(expected in html, True)
def testWithSingleSubtitle(self):
......
......@@ -158,7 +158,7 @@ analyses:
Zope responds to this with a success response like this:
<?xml version="1.0" encoding="iso-8859-15" ?>
<?xml version="1.0" encoding="utf-8" ?>
<d:prop xmlns:d="DAV:">
<d:lockdiscovery>
<d:activelock>
......
......@@ -26,7 +26,7 @@ TODO:
NOTE: So far i didn't have any problems.
If you have problems please report them.
- We are using a hardcoded default of latin-1 for encoding unicode
- We are using a hardcoded default of utf-8 for encoding unicode
strings. While this is suboptimal, it does match the expected
encoding from OFS.PropertySheet. We need to find a the encoding
somehow, maybe use the same encoding as the ZMI is using?
......@@ -59,11 +59,11 @@ def unescape(value, entities=None):
_ent.update(entities)
return _unescape(value, entities)
# XXX latin-1 is hardcoded on OFS.PropertySheets as the expected
# utf-8 is hardcoded on OFS.PropertySheets as the expected
# encoding properties will be stored in. Optimally, we should use the
# same encoding as the 'default_encoding' property that is used for
# the ZMI.
zope_encoding = 'latin-1'
zope_encoding = 'utf-8'
class Node:
""" Our nodes no matter what type
......
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