aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ingmar Vanhassel <ingmar@exherbo.org> 2009-10-29 12:13:20 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-10-31 19:31:43 +0000
commitc1f9a1cf3500c748a98aaf75c4f929d9fa826034 (patch)
treef73c0fbed9362b7e48020de4cd2976cd403e9692
parent4b56546fdc69ee084ec68fec78d93965c35d48ac (diff)
downloadpaludis-c1f9a1cf3500c748a98aaf75c4f929d9fa826034.tar.gz
paludis-c1f9a1cf3500c748a98aaf75c4f929d9fa826034.tar.xz
Better error message for cat/foo[=1.2.3]::bar
-rw-r--r--paludis/elike_package_dep_spec.cc5
-rw-r--r--paludis/user_dep_spec.cc5
2 files changed, 8 insertions, 2 deletions
diff --git a/paludis/elike_package_dep_spec.cc b/paludis/elike_package_dep_spec.cc
index 7459e7a84..738d72594 100644
--- a/paludis/elike_package_dep_spec.cc
+++ b/paludis/elike_package_dep_spec.cc
@@ -96,9 +96,12 @@ paludis::elike_remove_trailing_square_bracket_if_exists(std::string & s, Partial
if (std::string::npos == ((use_group_p = s.rfind('['))))
return false;
- if (s.at(s.length() - 1) != ']')
+ if (std::string::npos == s.rfind(']'))
throw PackageDepSpecError("Mismatched []");
+ if (s.at(s.length() - 1) != ']')
+ throw PackageDepSpecError("Trailing garbage after [] block");
+
std::string flag(s.substr(use_group_p + 1));
if (flag.length() < 2)
throw PackageDepSpecError("Invalid [] contents");
diff --git a/paludis/user_dep_spec.cc b/paludis/user_dep_spec.cc
index bcc85e80d..a36ef7d2c 100644
--- a/paludis/user_dep_spec.cc
+++ b/paludis/user_dep_spec.cc
@@ -98,9 +98,12 @@ namespace
if (std::string::npos == ((use_group_p = s.rfind('['))))
return false;
- if (s.at(s.length() - 1) != ']')
+ if (std::string::npos == s.rfind(']'))
throw PackageDepSpecError("Mismatched []");
+ if (s.at(s.length() - 1) != ']')
+ throw PackageDepSpecError("Trailing garbage after [] block");
+
std::string flag(s.substr(use_group_p + 1));
if (flag.length() < 2)
throw PackageDepSpecError("Invalid [] contents");