summaryrefslogtreecommitdiffstats
path: root/tests/test_manifest_xml.py
diff options
context:
space:
mode:
authorChris Allen <chris.allen@arm.com>2023-10-20 16:35:39 +0100
committerLUCI <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-10-20 18:22:59 +0000
commit7393f6bc414ae5d140101fffcb48148a36b80f64 (patch)
tree636b5fc909145e85e7e0ab160b8241287ae6cbf0 /tests/test_manifest_xml.py
parent8dd85218541f66b5c6740e46ebb3ebbcfc585af1 (diff)
downloadgit-repo-7393f6bc414ae5d140101fffcb48148a36b80f64.tar.gz
manifest_xml: Fix empty project list when DOCTYPE is present
When parsing the manifest XML, the code looks for a top level DOM node named "manifest". However, it doesn't check that it's an element type node so if there is also an XML document type declaration node present (which has the same name as the root element) then it selects the wrong node and hence you end up with no projects defined at all. Change-Id: I8d101caffbbc2a06e56136ff21302e3f09cfc96b Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/390357 Reviewed-by: Mike Frysinger <vapier@google.com> Tested-by: Chris Allen <chris.allen@arm.com> Commit-Queue: Chris Allen <chris.allen@arm.com>
Diffstat (limited to 'tests/test_manifest_xml.py')
-rw-r--r--tests/test_manifest_xml.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/test_manifest_xml.py b/tests/test_manifest_xml.py
index 1015e114..bd255dcc 100644
--- a/tests/test_manifest_xml.py
+++ b/tests/test_manifest_xml.py
@@ -385,6 +385,21 @@ class XmlManifestTests(ManifestParseTestCase):
385 "</manifest>", 385 "</manifest>",
386 ) 386 )
387 387
388 def test_parse_with_xml_doctype(self):
389 """Check correct manifest parse with DOCTYPE node present."""
390 manifest = self.getXmlManifest(
391 """<?xml version="1.0" encoding="UTF-8"?>
392<!DOCTYPE manifest []>
393<manifest>
394 <remote name="test-remote" fetch="http://localhost" />
395 <default remote="test-remote" revision="refs/heads/main" />
396 <project name="test-project" path="src/test-project"/>
397</manifest>
398"""
399 )
400 self.assertEqual(len(manifest.projects), 1)
401 self.assertEqual(manifest.projects[0].name, "test-project")
402
388 403
389class IncludeElementTests(ManifestParseTestCase): 404class IncludeElementTests(ManifestParseTestCase):
390 """Tests for <include>.""" 405 """Tests for <include>."""