[Zope3-checkins] SVN: Zope3/trunk/src/zope/app/file/browser/file.py use proper content-type parsing when checking for a charset declaration

Fred L. Drake, Jr. fdrake at gmail.com
Fri Jul 29 21:19:25 EDT 2005


Log message for revision 37589:
  use proper content-type parsing when checking for a charset declaration

Changed:
  U   Zope3/trunk/src/zope/app/file/browser/file.py

-=-
Modified: Zope3/trunk/src/zope/app/file/browser/file.py
===================================================================
--- Zope3/trunk/src/zope/app/file/browser/file.py	2005-07-30 01:12:11 UTC (rev 37588)
+++ Zope3/trunk/src/zope/app/file/browser/file.py	2005-07-30 01:19:24 UTC (rev 37589)
@@ -20,6 +20,7 @@
 
 import zope.event
 
+from zope.publisher import contenttype
 from zope.schema import Text
 from zope.app import content_types
 from zope.app.event import objectevent
@@ -391,6 +392,8 @@
         'ASCII'
 
     """
-    if 'charset=' not in content_type:
-        return 'ASCII'
-    return content_type.split('charset=')[1]
+    if content_type and content_type.strip():
+        major, minor, params = contenttype.parse(content_type)
+        return params.get("charset", "ASCII")
+    else:
+        return "ASCII"



More information about the Zope3-Checkins mailing list