aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-19 12:13:30 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-08-19 21:14:38 +0100
commitc351c6097f5072696285e6dd88808e70446d6a22 (patch)
tree6721dad0eed7f9f63ccbb9a169d7bd3b0704cb5b
parent86f4998ea2441fcd6870f19fb312659dfb81e92e (diff)
downloadpaludis-c351c6097f5072696285e6dd88808e70446d6a22.tar.gz
paludis-c351c6097f5072696285e6dd88808e70446d6a22.tar.xz
Prevent MYOPTIONS abuses
-rw-r--r--paludis/repositories/e/e_choices_key.cc6
-rw-r--r--paludis/repositories/e/myoption.cc5
-rw-r--r--paludis/repositories/e/myoption.hh8
3 files changed, 19 insertions, 0 deletions
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc
index 49db72f..769f3eb 100644
--- a/paludis/repositories/e/e_choices_key.cc
+++ b/paludis/repositories/e/e_choices_key.cc
@@ -149,6 +149,9 @@ namespace
p = prefixes.insert(std::make_pair(*current_prefix_stack.begin(), Values())).first;
UnprefixedChoiceName n(parse_myoption(node.spec()->text()).first);
+ if (std::string::npos != stringify(n).find(':'))
+ throw MyOptionsError("Flag '" + stringify(n) + "' must not contain a ':'");
+
Values::iterator v(p->second.find(n));
if (v == p->second.end())
v = p->second.insert(std::make_pair(n, Annotations())).first;
@@ -175,6 +178,9 @@ namespace
void visit(const PlainTextSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node)
{
+ if (node.spec()->label() == "build_options")
+ throw MyOptionsError("Label 'build_options' is not for package use");
+
*current_prefix_stack.begin() = ChoicePrefixName(node.spec()->label());
}
diff --git a/paludis/repositories/e/myoption.cc b/paludis/repositories/e/myoption.cc
index e288ae1..2fe8e0f 100644
--- a/paludis/repositories/e/myoption.cc
+++ b/paludis/repositories/e/myoption.cc
@@ -23,6 +23,11 @@
using namespace paludis;
using namespace paludis::erepository;
+MyOptionsError::MyOptionsError(const std::string & m) throw () :
+ Exception(m)
+{
+}
+
std::pair<UnprefixedChoiceName, bool>
paludis::erepository::parse_myoption(const std::string & s)
{
diff --git a/paludis/repositories/e/myoption.hh b/paludis/repositories/e/myoption.hh
index 871bfc5..f8f3e8e 100644
--- a/paludis/repositories/e/myoption.hh
+++ b/paludis/repositories/e/myoption.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_MYOPTION_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/util/exception.hh>
#include <paludis/choice-fwd.hh>
#include <utility>
#include <string>
@@ -29,6 +30,13 @@ namespace paludis
{
namespace erepository
{
+ class PALUDIS_VISIBLE MyOptionsError :
+ public Exception
+ {
+ public:
+ MyOptionsError(const std::string & message) throw ();
+ };
+
std::pair<UnprefixedChoiceName, bool> parse_myoption(const std::string &) PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
}
}