~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to lib/common/zip.py

  • Committer: dcoles
  • Date: 2008-04-18 07:37:50 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:742
Libs: lxml requires extra shared objects

Show diffs side-by-side

added added

removed removed

Lines of Context:
91
91
    Note: All files go directly into the path. To avoid having a "zip bomb"
92
92
    situation, the zip file should have a single directory in it with all the
93
93
    files.
94
 
    The path is an absolute path in the current filesystem
95
 
    (if this code is executed inside the jail, then it's inside the jail,
96
 
    if it's not then it's not).
97
94
    """
98
95
    zip = zipfile.ZipFile(file, 'r')
99
96
    # First test the zip file
101
98
        raise OSError("ZIP: Bad zip file")
102
99
 
103
100
    for filename in zip.namelist():
104
 
        localpath = os.path.join(path, filename)
 
101
        # Work out the name of this file on the local file system, and make
 
102
        # sure it is valid
 
103
        relpath = os.path.join(path, filename)
 
104
        _, localpath = studpath.url_to_local(relpath)
 
105
        if localpath is None:
 
106
            raise OSError("ZIP: Permission denied")
105
107
        # Create directory for filename
106
108
        (file_dir, _) = os.path.split(localpath)
107
109
        if not os.path.exists(file_dir):