[Checkins] SVN: zope.publisher/trunk/src/zope/publisher/ A trivial
'HTTP_ACCEPT_CHARSET' header is now treated similar to when
it's not set at all. This fixes #143873,
which is an issue only for Zope 2.
Malthe Borch
mborch at gmail.com
Wed Mar 12 11:10:41 EDT 2008
Log message for revision 84616:
A trivial 'HTTP_ACCEPT_CHARSET' header is now treated similar to when it's not set at all. This fixes #143873, which is an issue only for Zope 2.
Changed:
U zope.publisher/trunk/src/zope/publisher/http.py
U zope.publisher/trunk/src/zope/publisher/tests/test_httpcharsets.py
-=-
Modified: zope.publisher/trunk/src/zope/publisher/http.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/http.py 2008-03-12 13:57:00 UTC (rev 84615)
+++ zope.publisher/trunk/src/zope/publisher/http.py 2008-03-12 15:10:40 UTC (rev 84616)
@@ -923,7 +923,7 @@
'''See interface IUserPreferredCharsets'''
charsets = []
sawstar = sawiso88591 = 0
- header_present = 'HTTP_ACCEPT_CHARSET' in self.request
+ header_present = bool(self.request.get('HTTP_ACCEPT_CHARSET'))
for charset in self.request.get('HTTP_ACCEPT_CHARSET', '').split(','):
charset = charset.strip().lower()
if charset:
Modified: zope.publisher/trunk/src/zope/publisher/tests/test_httpcharsets.py
===================================================================
--- zope.publisher/trunk/src/zope/publisher/tests/test_httpcharsets.py 2008-03-12 13:57:00 UTC (rev 84615)
+++ zope.publisher/trunk/src/zope/publisher/tests/test_httpcharsets.py 2008-03-12 15:10:40 UTC (rev 84616)
@@ -78,7 +78,17 @@
self.assertEqual(list(browser_charsets.getPreferredCharsets()),
[])
+ def testTrivialHTTP_ACCEPT_CHARSET(self):
+ # If the client provides a trivial HTTP_ACCEPT_CHARSET, it should
+ # accept any charset (this test is aimed at Zope 2's handling
+ # of request queries for entries starting with HTTP_
+ # See: https://bugs.launchpad.net/zope2/+bug/143873
+ request = {'HTTP_ACCEPT_CHARSET': ''}
+ browser_charsets = HTTPCharsets(request)
+ self.assertEqual(list(browser_charsets.getPreferredCharsets()),
+ [])
+
def test_suite():
loader=unittest.TestLoader()
return loader.loadTestsFromTestCase(HTTPCharsetTest)
More information about the Checkins
mailing list