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

« back to all changes in this revision

Viewing changes to www/common/studpath.py

  • Committer: mattgiuca
  • Date: 2007-12-21 06:22:05 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:125
common/studpath.py: Normalise and check path for ".." to disallow
        access outside the given student directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
    See also: conf.jail_base
48
48
    """
 
49
    # First normalise the path
 
50
    urlpath = os.path.normpath(urlpath)
 
51
    # Now if it begins with ".." then it's illegal
 
52
    if urlpath.startswith(".."):
 
53
        return (None, None)
49
54
    # Note: User can be a group name. There is absolutely no difference in our
50
55
    # current directory scheme.
51
56
    (user, subpath) = util.split_path(urlpath)
74
79
    >>> url_to_jailpaths("")
75
80
    (None, None, None)
76
81
    """
 
82
    # First normalise the path
 
83
    urlpath = os.path.normpath(urlpath)
 
84
    # Now if it begins with ".." then it's illegal
 
85
    if urlpath.startswith(".."):
 
86
        return (None, None, None)
77
87
    # Note: User can be a group name. There is absolutely no difference in our
78
88
    # current directory scheme.
79
89
    (user, subpath) = util.split_path(urlpath)