equal
deleted
inserted
replaced
31 def fail(message): |
31 def fail(message): |
32 #logfile.write("Fail: %s\n" % message) |
32 #logfile.write("Fail: %s\n" % message) |
33 sys.stderr.write(message + "\n") |
33 sys.stderr.write(message + "\n") |
34 sys.exit(-1) |
34 sys.exit(-1) |
35 |
35 |
36 allowedchars = "A-Za-z0-9_.-" |
36 # Note that this currently disallows dots in path components - if you change it |
|
37 # to allow them ensure that "." and ".." are disallowed in path components. |
|
38 allowedchars = "A-Za-z0-9_-" |
37 goodpathre = re.compile("([%s]+/)*[%s]+$" % (allowedchars, allowedchars)) |
39 goodpathre = re.compile("([%s]+/)*[%s]+$" % (allowedchars, allowedchars)) |
38 def goodpath(path): |
40 def goodpath(path): |
39 if goodpathre.match(path) is None: |
41 if goodpathre.match(path) is None: |
40 fail("Disallowing path: %s" % path) |
42 fail("Disallowing path: %s" % path) |
41 |
43 |