aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-09-10 18:30:57 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-09-10 18:30:57 +0200
commitdc4ba51c218998a4f3b64d1681e66ddedf10c2f2 (patch)
treef9e0e69afe70717ea8ee76031d151ea52314a24b /bpkg/manifest.cxx
parenta51f5787d3e2da61f75da6b38d43f1cae2f7c1f0 (diff)
Add package manifest location validation in package_manifests parsing and serialization
Diffstat (limited to 'bpkg/manifest.cxx')
-rw-r--r--bpkg/manifest.cxx18
1 files changed, 17 insertions, 1 deletions
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.
}