[Zope3-checkins] SVN: Zope3/trunk/src/zope/publisher/ Thanks to
Bjorn, who pointed out the real issue with Roger's bug. URLs
Stephan Richter
srichter at cosmos.phy.tufts.edu
Mon Sep 19 15:01:13 EDT 2005
Log message for revision 38528:
Thanks to Bjorn, who pointed out the real issue with Roger's bug. URLs
should only contain ASCII chars anyways.
Changed:
U Zope3/trunk/src/zope/publisher/browser.py
U Zope3/trunk/src/zope/publisher/tests/test_browserresponse.py
-=-
Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py 2005-09-19 18:47:29 UTC (rev 38527)
+++ Zope3/trunk/src/zope/publisher/browser.py 2005-09-19 19:01:13 UTC (rev 38528)
@@ -694,12 +694,8 @@
index = match.start(0) + len(match.group(0))
ibase = base_re_search(body)
if ibase is None:
- base = self.getBase()
# Make sure the base URL is not a unicode string.
- if isinstance(base, unicode):
- ma, mi, params = contenttype.parse(content_type)
- encoding = params.get('charset', 'utf8')
- base = base.encode(encoding)
+ base = str(self.getBase())
body = ('%s\n<base href="%s" />\n%s' %
(body[:index], base, body[index:]))
return body
Modified: Zope3/trunk/src/zope/publisher/tests/test_browserresponse.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_browserresponse.py 2005-09-19 18:47:29 UTC (rev 38527)
+++ Zope3/trunk/src/zope/publisher/tests/test_browserresponse.py 2005-09-19 19:01:13 UTC (rev 38528)
@@ -100,10 +100,12 @@
self.assert_(isinstance(body, str))
self.assert_('<base href="http://localhost/folder/" />' in body)
- response.setBase(u'http://localhost/\xdcbung')
- result = insertBase('<html><head></head><body>Page</body></html>')
+ # Ensure that encoded bodies work, when a base is inserted.
+ response.setBase('http://localhost/folder')
+ result = insertBase(
+ '<html><head></head><body>\xc3\x9bung</body></html>')
self.assert_(isinstance(body, str))
- self.assert_('<base href="http://localhost/\xc3\x9cbung" />' in result)
+ self.assert_('<base href="http://localhost/folder" />' in result)
def test_interface(self):
More information about the Zope3-Checkins
mailing list