[Checkins] SVN: zope.contenttype/trunk/src/zope/contenttype/ some more checks

Andreas Jung andreas at andreas-jung.com
Sun Sep 16 06:43:49 EDT 2007


Log message for revision 79689:
  some more checks
  

Changed:
  U   zope.contenttype/trunk/src/zope/contenttype/__init__.py
  U   zope.contenttype/trunk/src/zope/contenttype/tests/testContentTypes.py

-=-
Modified: zope.contenttype/trunk/src/zope/contenttype/__init__.py
===================================================================
--- zope.contenttype/trunk/src/zope/contenttype/__init__.py	2007-09-16 10:34:55 UTC (rev 79688)
+++ zope.contenttype/trunk/src/zope/contenttype/__init__.py	2007-09-16 10:43:48 UTC (rev 79689)
@@ -38,7 +38,8 @@
     while s[i] in string.whitespace: 
        i += 1
 
-    s = s[i : i+iMAXLEN].lower()
+    s2 = s[i : i+iMAXLEN]
+    s = s2.lower()
     
     if s.startswith('<html>'):
         return 'text/html'
@@ -47,7 +48,7 @@
         return 'text/html'
 
     # what about encodings??
-    if s.startswith('<?xml'):
+    if s2.startswith('<?xml'):
         return 'text/xml'
     
     return 'text/plain'

Modified: zope.contenttype/trunk/src/zope/contenttype/tests/testContentTypes.py
===================================================================
--- zope.contenttype/trunk/src/zope/contenttype/tests/testContentTypes.py	2007-09-16 10:34:55 UTC (rev 79688)
+++ zope.contenttype/trunk/src/zope/contenttype/tests/testContentTypes.py	2007-09-16 10:43:48 UTC (rev 79689)
@@ -75,6 +75,8 @@
         self.assertEqual(t('<HtmL><body>hello world</body></html>'), 
                          'text/html')
         self.assertEqual(t('<?xml version="1.0"><foo/>'), 'text/xml')
+        self.assertEqual(t('<?XML version="1.0"><foo/>'), 'text/plain')
+        self.assertEqual(t('foo bar'), 'text/plain')
         self.assertEqual(t('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"' +
                            ' "http://www.w3.org/TR/html4/loose.dtd">'),
                            'text/html')



More information about the Checkins mailing list