mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
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>
This commit is contained in:
parent
8dd8521854
commit
7393f6bc41
@ -1266,7 +1266,10 @@ https://gerrit.googlesource.com/git-repo/+/HEAD/docs/manifest-format.md
|
|||||||
raise ManifestParseError("no root node in %s" % (path,))
|
raise ManifestParseError("no root node in %s" % (path,))
|
||||||
|
|
||||||
for manifest in root.childNodes:
|
for manifest in root.childNodes:
|
||||||
if manifest.nodeName == "manifest":
|
if (
|
||||||
|
manifest.nodeType == manifest.ELEMENT_NODE
|
||||||
|
and manifest.nodeName == "manifest"
|
||||||
|
):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
raise ManifestParseError("no <manifest> in %s" % (path,))
|
raise ManifestParseError("no <manifest> in %s" % (path,))
|
||||||
|
@ -385,6 +385,21 @@ class XmlManifestTests(ManifestParseTestCase):
|
|||||||
"</manifest>",
|
"</manifest>",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_parse_with_xml_doctype(self):
|
||||||
|
"""Check correct manifest parse with DOCTYPE node present."""
|
||||||
|
manifest = self.getXmlManifest(
|
||||||
|
"""<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE manifest []>
|
||||||
|
<manifest>
|
||||||
|
<remote name="test-remote" fetch="http://localhost" />
|
||||||
|
<default remote="test-remote" revision="refs/heads/main" />
|
||||||
|
<project name="test-project" path="src/test-project"/>
|
||||||
|
</manifest>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
self.assertEqual(len(manifest.projects), 1)
|
||||||
|
self.assertEqual(manifest.projects[0].name, "test-project")
|
||||||
|
|
||||||
|
|
||||||
class IncludeElementTests(ManifestParseTestCase):
|
class IncludeElementTests(ManifestParseTestCase):
|
||||||
"""Tests for <include>."""
|
"""Tests for <include>."""
|
||||||
|
Loading…
Reference in New Issue
Block a user