~ubuntu-branches/ubuntu/utopic/python-django/utopic

« back to all changes in this revision

Viewing changes to django/core/files/images.py

  • Committer: Package Import Robot
  • Author(s): Raphaël Hertzog
  • Date: 2012-08-02 10:44:02 UTC
  • mfrom: (1.1.17) (4.4.20 sid)
  • Revision ID: package-import@ubuntu.com-20120802104402-x26ethgm9s21la1y
* New upstream security and maintenance release. Closes: #683364
  Fixes: CVE-2012-3442 CVE-2012-3443 CVE-2012-3444
* Drop 01_disable_broken_test.diff and 04_hyphen-manpage.diff which
  have been merged upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
47
47
        file = open(file_or_path, 'rb')
48
48
        close = True
49
49
    try:
 
50
        # Most of the time PIL only needs a small chunk to parse the image and
 
51
        # get the dimensions, but with some TIFF files PIL needs to parse the
 
52
        # whole file.
 
53
        chunk_size = 1024
50
54
        while 1:
51
 
            data = file.read(1024)
 
55
            data = file.read(chunk_size)
52
56
            if not data:
53
57
                break
54
58
            p.feed(data)
55
59
            if p.image:
56
60
                return p.image.size
 
61
            chunk_size = chunk_size*2
57
62
        return None
58
63
    finally:
59
64
        if close: