diff options
author | Alon Zakai <alonzakai@gmail.com> | 2013-07-31 14:00:44 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2013-07-31 14:09:27 -0700 |
commit | e4ec9607364da091419c1b909e585e59da27e9d7 (patch) | |
tree | 2a86a08a39ad6ff020d2f940f535d2828347f677 /tools | |
parent | b786b5ed8a1d709b67d7dc80e8ba41bbaf6e58ae (diff) |
absolutize and verify paths in the file packager
Diffstat (limited to 'tools')
-rw-r--r-- | tools/file_packager.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tools/file_packager.py b/tools/file_packager.py index 575e5957..0fa6a529 100644 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -198,6 +198,17 @@ for file_ in data_files: os.path.walk(file_['srcpath'], add, [file_['mode'], file_['srcpath'], file_['dstpath']]) data_files = filter(lambda file_: not os.path.isdir(file_['srcpath']), data_files) +# Absolutize paths, and check that they make sense +curr_abspath = os.path.abspath(os.getcwd()) +for file_ in data_files: + path = file_['dstpath'] + abspath = os.path.abspath(path) + print >> sys.stderr, path, abspath, curr_abspath + if not abspath.startswith(curr_abspath): + print >> sys.stderr, 'Error: Embedding "%s" which is below the current directory. This is invalid since the current directory becomes the root that the generated code will see' % path + sys.exit(1) + file_['dstpath'] = abspath[len(curr_abspath)+1:] + for file_ in data_files: file_['dstpath'] = file_['dstpath'].replace(os.path.sep, '/') # name in the filesystem, native and emulated if file_['dstpath'].endswith('/'): # If user has submitted a directory name as the destination but omitted the destination filename, use the filename from source file |