aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-06 13:36:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-06 13:36:39 +0000
commit12a818efe70650e7f1bc300651c687ffd225df05 (patch)
tree44404d043898690e8babe28f7a8e3bc0ca59c558
parent1e7ffe1e100256244b980ed9fecf04f051c02b4d (diff)
downloadpaludis-12a818efe70650e7f1bc300651c687ffd225df05.tar.gz
paludis-12a818efe70650e7f1bc300651c687ffd225df05.tar.xz
Turn choice name validation back on
Fixes: ticket:1050
-rw-r--r--paludis/choice.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/paludis/choice.cc b/paludis/choice.cc
index 4604872..76adf44 100644
--- a/paludis/choice.cc
+++ b/paludis/choice.cc
@@ -62,7 +62,7 @@ WrappedValueTraits<ChoicePrefixNameTag>::validate(const std::string & s)
case ':':
case '_':
return false;
- };
+ }
switch (s.at(0))
{
@@ -70,12 +70,13 @@ WrappedValueTraits<ChoicePrefixNameTag>::validate(const std::string & s)
case '_':
case '-':
return false;
- };
+ }
- if (s[0] >= 'A' && s[0] <= 'Z')
- return false;
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "0123456789-_+");
- if (std::string::npos != s.find(" \t\r\n()#"))
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
return false;
}
@@ -91,14 +92,14 @@ bool
WrappedValueTraits<ChoiceNameWithPrefixTag>::validate(const std::string & s)
{
if (s.empty())
- throw ChoiceNameWithPrefixError(s);
+ return false;
switch (s.at(s.length() - 1))
{
case ':':
case '_':
return false;
- };
+ }
switch (s.at(0))
{
@@ -106,9 +107,14 @@ WrappedValueTraits<ChoiceNameWithPrefixTag>::validate(const std::string & s)
case '_':
case '-':
return false;
- };
+ }
+
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-_+@:.");
- if (std::string::npos != s.find(" \t\r\n()#"))
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
return false;
return true;
@@ -130,8 +136,7 @@ WrappedValueTraits<UnprefixedChoiceNameTag>::validate(const std::string & s)
case ':':
case '_':
return false;
- break;
- };
+ }
switch (s.at(0))
{
@@ -139,10 +144,14 @@ WrappedValueTraits<UnprefixedChoiceNameTag>::validate(const std::string & s)
case '_':
case '-':
return false;
- break;
- };
+ }
+
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-_+@.");
- if (std::string::npos != s.find(" \t\r\n()#"))
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
return false;
return true;