From ae625410057cdf8e905282161af7cf1b353d3cc3 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 10 Feb 2020 17:10:03 -0500 Subject: manifest_xml: allow src=. with symlinks Some Android/Nest manifests are using with src="." to create stable paths to specific projects. Allow that specific use case as it seems reasonable to support. Bug: https://crbug.com/gerrit/11218 Change-Id: I5eadec257cd58ba0f8687c590ddc250a7a414a85 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/254276 Reviewed-by: Michael Mortensen Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- manifest_xml.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'manifest_xml.py') diff --git a/manifest_xml.py b/manifest_xml.py index 035cc61b..b92b2675 100644 --- a/manifest_xml.py +++ b/manifest_xml.py @@ -985,11 +985,13 @@ class XmlManifest(object): # Assume paths might be used on case-insensitive filesystems. path = path.lower() - # We don't really need to reject '.' here, but there shouldn't really be a - # need to ever use it, so no need to accept it either. - for part in set(path.split(os.path.sep)): - if part in {'.', '..', '.git'} or part.startswith('.repo'): - return 'bad component: %s' % (part,) + # Some people use src="." to create stable links to projects. Lets allow + # that but reject all other uses of "." to keep things simple. + parts = path.split(os.path.sep) + if parts != ['.']: + for part in set(parts): + if part in {'.', '..', '.git'} or part.startswith('.repo'): + return 'bad component: %s' % (part,) if not symlink and path.endswith(os.path.sep): return 'dirs not allowed' -- cgit v1.2.3-54-g00ecf