From dc4ba51c218998a4f3b64d1681e66ddedf10c2f2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 10 Sep 2015 18:30:57 +0200 Subject: Add package manifest location validation in package_manifests parsing and serialization --- bpkg/manifest.cxx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'bpkg') diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx index 4cbaad5..40f362e 100644 --- a/bpkg/manifest.cxx +++ b/bpkg/manifest.cxx @@ -778,15 +778,31 @@ namespace bpkg package_manifests:: package_manifests (parser& p) { - for (name_value nv (p.next ()); !nv.empty (); nv = p.next ()) + name_value nv (p.next ()); + while (!nv.empty ()) + { push_back (package_manifest (p, nv)); + nv = p.next (); + + if (!back ().location) + throw parsing (p.name (), nv.name_line, nv.name_column, + "package location expected"); + } } void package_manifests:: serialize (serializer& s) const { for (const package_manifest& p: *this) + { + if (!p.location || p.location->empty ()) + throw + serialization ( + s.name (), + "no valid location for " + p.name + "-" + p.version.string ()); + p.serialize (s); + } s.next ("", ""); // End of stream. } -- cgit v1.1