summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
Diffstat (limited to 'manifest_xml.py')
-rw-r--r--manifest_xml.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 41628003..fe0735a8 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -1010,19 +1010,30 @@ class XmlManifest(object):
1010 # Assume paths might be used on case-insensitive filesystems. 1010 # Assume paths might be used on case-insensitive filesystems.
1011 path = path.lower() 1011 path = path.lower()
1012 1012
1013 # Split up the path by its components. We can't use os.path.sep exclusively
1014 # as some platforms (like Windows) will convert / to \ and that bypasses all
1015 # our constructed logic here. Especially since manifest authors only use
1016 # / in their paths.
1017 resep = re.compile(r'[/%s]' % re.escape(os.path.sep))
1018 parts = resep.split(path)
1019
1013 # Some people use src="." to create stable links to projects. Lets allow 1020 # Some people use src="." to create stable links to projects. Lets allow
1014 # that but reject all other uses of "." to keep things simple. 1021 # that but reject all other uses of "." to keep things simple.
1015 parts = path.split(os.path.sep)
1016 if parts != ['.']: 1022 if parts != ['.']:
1017 for part in set(parts): 1023 for part in set(parts):
1018 if part in {'.', '..', '.git'} or part.startswith('.repo'): 1024 if part in {'.', '..', '.git'} or part.startswith('.repo'):
1019 return 'bad component: %s' % (part,) 1025 return 'bad component: %s' % (part,)
1020 1026
1021 if not symlink and path.endswith(os.path.sep): 1027 if not symlink and resep.match(path[-1]):
1022 return 'dirs not allowed' 1028 return 'dirs not allowed'
1023 1029
1030 # NB: The two abspath checks here are to handle platforms with multiple
1031 # filesystem path styles (e.g. Windows).
1024 norm = os.path.normpath(path) 1032 norm = os.path.normpath(path)
1025 if norm == '..' or norm.startswith('../') or norm.startswith(os.path.sep): 1033 if (norm == '..' or
1034 (len(norm) >= 3 and norm.startswith('..') and resep.match(norm[0])) or
1035 os.path.isabs(norm) or
1036 norm.startswith('/')):
1026 return 'path cannot be outside' 1037 return 'path cannot be outside'
1027 1038
1028 @classmethod 1039 @classmethod