[Zope3-checkins] SVN: Zope3/branches/3.2/ backported getImageInfo fix

Bernd Dorn bernd.dorn at fhv.at
Fri Sep 29 15:51:27 EDT 2006


Log message for revision 70443:
  backported getImageInfo fix

Changed:
  U   Zope3/branches/3.2/doc/CHANGES.txt
  U   Zope3/branches/3.2/src/zope/app/file/image.py
  U   Zope3/branches/3.2/src/zope/app/file/tests/test_image.py

-=-
Modified: Zope3/branches/3.2/doc/CHANGES.txt
===================================================================
--- Zope3/branches/3.2/doc/CHANGES.txt	2006-09-29 08:40:05 UTC (rev 70442)
+++ Zope3/branches/3.2/doc/CHANGES.txt	2006-09-29 19:51:26 UTC (rev 70443)
@@ -10,6 +10,9 @@
 
     Bug fixes
 
+      - Fixed a bug in getImageInfo which could cause an
+        UnboundLocalError under certain conditions.
+    
       - Fix invariant error handling in formlib. The exception Invalid raised
         in interface invariants where end in a component lookup error because
         this exception didn't get converted to a usefull error message.

Modified: Zope3/branches/3.2/src/zope/app/file/image.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/file/image.py	2006-09-29 08:40:05 UTC (rev 70442)
+++ Zope3/branches/3.2/src/zope/app/file/image.py	2006-09-29 19:51:26 UTC (rev 70443)
@@ -134,6 +134,8 @@
         jpeg.read(2)
         b = jpeg.read(1)
         try:
+            w = -1
+            h = -1
             while (b and ord(b) != 0xDA):
                 while (ord(b) != 0xFF): b = jpeg.read(1)
                 while (ord(b) == 0xFF): b = jpeg.read(1)

Modified: Zope3/branches/3.2/src/zope/app/file/tests/test_image.py
===================================================================
--- Zope3/branches/3.2/src/zope/app/file/tests/test_image.py	2006-09-29 08:40:05 UTC (rev 70442)
+++ Zope3/branches/3.2/src/zope/app/file/tests/test_image.py	2006-09-29 19:51:26 UTC (rev 70443)
@@ -156,6 +156,10 @@
         self.assertEqual(s.sizeForDisplay().mapping['width'], '?')
         self.assertEqual(s.sizeForDisplay().mapping['height'], '?')
 
+    def test_getImageInfo(self):
+        from zope.app.file.image import getImageInfo
+        t, w, h = getImageInfo("\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x00\x00\x01\x00\x01\x00\x00\xff\xdb\x00C")
+
 def test_suite():
     return unittest.TestSuite((
         unittest.makeSuite(TestImage),



More information about the Zope3-Checkins mailing list