[Checkins] SVN: zc.resourcelibrary/trunk/ changed MIME type handling to be more restrictive about whitespace

Thomas Lotze tl at gocept.com
Wed Dec 5 16:48:15 EST 2007


Log message for revision 82145:
  changed MIME type handling to be more restrictive about whitespace

Changed:
  U   zc.resourcelibrary/trunk/CHANGES.txt
  U   zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
  U   zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py

-=-
Modified: zc.resourcelibrary/trunk/CHANGES.txt
===================================================================
--- zc.resourcelibrary/trunk/CHANGES.txt	2007-12-05 18:52:21 UTC (rev 82144)
+++ zc.resourcelibrary/trunk/CHANGES.txt	2007-12-05 21:48:15 UTC (rev 82145)
@@ -2,6 +2,12 @@
 CHANGES
 =======
 
+0.8.1 (2007-12-05)
+------------------
+
+- changed MIME type handling to be more restrictive about whitespace to
+  conform to RfC 2045
+
 0.8 (2007-12-04)
 ----------------
 

Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt	2007-12-05 18:52:21 UTC (rev 82144)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/README.txt	2007-12-05 21:48:15 UTC (rev 82145)
@@ -186,14 +186,15 @@
     >>> '/@@/my-lib/included.js' in zpt(page, content_type='text/none')
     False
 
-This works also if the content type is spelled in a funny way and contains
-whitespace (leading whitespace and funny spelling of the major type will cause
-the publisher to complain so we don't try that here):
+This also works if the content type contains uppercase characters, as per RfC
+2045 on the syntax of MIME type specifications (we can't test uppercase
+characters in the major type yet since the publisher is not completely up to
+the RfC on that detail yet):
 
-    >>> '/@@/my-lib/included.js' in zpt(page, content_type='text/hTMl  ')
+    >>> '/@@/my-lib/included.js' in zpt(page, content_type='text/hTMl')
     True
 
-    >>> '/@@/my-lib/included.js' in zpt(page, content_type='text/nOne ')
+    >>> '/@@/my-lib/included.js' in zpt(page, content_type='text/nOne')
     False
 
 Parameters to the content type can't fool the check either:
@@ -206,7 +207,20 @@
     ...     page, content_type='text/none; charset=utf-8')
     False
 
+The content type is, however, assumed to be a strictly valid MIME type
+specification, implying that it can't contain any whitespace up to the
+semicolon signalling the start of parameters, if any (again, we can't yet test
+whitespace around the major type as that would upset the publisher):
 
+    >>> '/@@/my-lib/included.js' in zpt(
+    ...     page, content_type='text/ xml')
+    False
+
+    >>> '/@@/my-lib/included.js' in zpt(
+    ...     page, content_type='text/xml ; charset=utf-8')
+    False
+
+
 Dependencies
 ------------
 

Modified: zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py
===================================================================
--- zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2007-12-05 18:52:21 UTC (rev 82144)
+++ zc.resourcelibrary/trunk/src/zc/resourcelibrary/publication.py	2007-12-05 21:48:15 UTC (rev 82145)
@@ -71,8 +71,8 @@
             if isHTML(body):
                 content_type = 'text/html'
 
-        # check the content type disregarding parameters, whitespace and case
-        if content_type.split(';', 1)[0].strip().lower() in (
+        # check the content type disregarding parameters and case
+        if content_type.split(';', 1)[0].lower() in (
             'text/html', 'text/xml'):
             #act on HTML and XML content only!
 



More information about the Checkins mailing list