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

« back to all changes in this revision

Viewing changes to lib/common/zip.py

  • Committer: mattgiuca
  • Date: 2008-02-29 01:18:22 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:621
Added 2 new apps: home and subjects. Both fairly incomplete, just a basic
    skeleton.
    "home" is the new default app, replacing "files".
    (It has a link to files).

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
            # Relative to req.path
52
52
            relpath = os.path.join(basepath, path)
53
53
 
54
 
        #_, r = studpath.url_to_local(relpath)
55
 
        r = relpath
 
54
        _, r = studpath.url_to_local(relpath)
56
55
        if r is None:
57
56
            raise OSError("ZIP: Invalid path")
58
57
        if not os.access(r, os.R_OK):
91
90
    Note: All files go directly into the path. To avoid having a "zip bomb"
92
91
    situation, the zip file should have a single directory in it with all the
93
92
    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
93
    """
98
94
    zip = zipfile.ZipFile(file, 'r')
99
95
    # First test the zip file
101
97
        raise OSError("ZIP: Bad zip file")
102
98
 
103
99
    for filename in zip.namelist():
104
 
        localpath = os.path.join(path, filename)
 
100
        # Work out the name of this file on the local file system, and make
 
101
        # sure it is valid
 
102
        relpath = os.path.join(path, filename)
 
103
        _, localpath = studpath.url_to_local(relpath)
 
104
        if localpath is None:
 
105
            raise OSError("ZIP: Permission denied")
105
106
        # Create directory for filename
106
107
        (file_dir, _) = os.path.split(localpath)
107
108
        if not os.path.exists(file_dir):