aboutsummaryrefslogtreecommitdiff
path: root/bpkg/manifest-utility.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-05-21 18:06:39 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-05-21 18:06:39 +0300
commit01b11f060e656c00f875d05a8d4b283f524b0358 (patch)
treed204e4de36bf5eb7213c2ef140bef467cbf6873e /bpkg/manifest-utility.cxx
parentc07da0ae583536b39c7627cd665c93b94df7aed0 (diff)
Add package name validation to parse_package_name() function
Diffstat (limited to 'bpkg/manifest-utility.cxx')
-rw-r--r--bpkg/manifest-utility.cxx18
1 files changed, 15 insertions, 3 deletions
diff --git a/bpkg/manifest-utility.cxx b/bpkg/manifest-utility.cxx
index 634f522..defa675 100644
--- a/bpkg/manifest-utility.cxx
+++ b/bpkg/manifest-utility.cxx
@@ -45,10 +45,22 @@ namespace bpkg
if (const char* p = traits::find (s, n, '/'))
n = static_cast<size_t> (p - s);
- if (n == 0)
- fail << "empty package name in '" << s << "'";
+ string nm (s, n);
- return string (s, n);
+ // The package name may be a part of some compound argument. So while the
+ // invalid package name would likely result in the operation failure, the
+ // validating can ease the troubleshooting.
+ //
+ try
+ {
+ validate_package_name (nm);
+ }
+ catch (const invalid_argument& e)
+ {
+ fail << "invalid package name in '" << s << "': " << e;
+ }
+
+ return nm;
}
version