summaryrefslogtreecommitdiffstats
path: root/manifest_xml.py
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2020-02-19 22:36:26 -0500
committerDavid Pursehouse <dpursehouse@collab.net>2020-02-21 05:17:05 +0000
commitd9254599f9bb47632313ecb90c5f281ceca5da3a (patch)
tree5c1bdb0815f5a027f0de194b488ba254719c7c11 /manifest_xml.py
parent746e7f664e306e823a40cd95a127516aa522ed8f (diff)
downloadgit-repo-d9254599f9bb47632313ecb90c5f281ceca5da3a.tar.gz
manifest/tests: get them passing under Windows
We also need to check more things in the manifest/project handlers, and use platform_utils in a few places to address Windows behavior. Drop Python 2.7 from Windows testing as it definitely doesn't work and we won't be fixing it. Change-Id: I83d00ee9f1612312bb3f7147cb9535fc61268245 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256113 Tested-by: Mike Frysinger <vapier@google.com> Reviewed-by: Jonathan Nieder <jrn@google.com> Reviewed-by: David Pursehouse <dpursehouse@collab.net>
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