From 541339720451b0a05dc7ebe83e17bafb89863c6f Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 1 Mar 2021 21:38:08 -0500 Subject: manifest: relax include name rules for user-specified path Allow the user to specify relative or absolute or any other funky path that they want when using `repo init` or `repo sync`. Our goal is to restrict the paths in the remote manifest git repo we cloned from the network, not protect the user from themselves. Bug: https://crbug.com/gerrit/14156 Change-Id: I1ccfb2a6bd1dce2bd765e261bef0bbf0f8a9beb6 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/298823 Reviewed-by: Jonathan Nieder Tested-by: Mike Frysinger --- tests/test_manifest_xml.py | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'tests/test_manifest_xml.py') diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py index f69e9cf8..6977b417 100644 --- a/tests/test_manifest_xml.py +++ b/tests/test_manifest_xml.py @@ -298,8 +298,8 @@ class IncludeElementTests(ManifestParseTestCase): # Check level2 proj group not removed. self.assertIn('l2g1', proj.groups) - def test_bad_name_checks(self): - """Check handling of bad name attribute.""" + def test_allow_bad_name_from_user(self): + """Check handling of bad name attribute from the user's input.""" def parse(name): manifest = self.getXmlManifest(f""" @@ -307,6 +307,34 @@ class IncludeElementTests(ManifestParseTestCase): +""") + # Force the manifest to be parsed. + manifest.ToXml() + + # Setup target of the include. + target = os.path.join(self.tempdir, 'target.xml') + with open(target, 'w') as fp: + fp.write('') + + # Include with absolute path. + parse(os.path.abspath(target)) + + # Include with relative path. + parse(os.path.relpath(target, self.manifest_dir)) + + def test_bad_name_checks(self): + """Check handling of bad name attribute.""" + def parse(name): + # Setup target of the include. + with open(os.path.join(self.manifest_dir, 'target.xml'), 'w') as fp: + fp.write(f'') + + manifest = self.getXmlManifest(""" + + + + + """) # Force the manifest to be parsed. manifest.ToXml() -- cgit v1.2.3-54-g00ecf