aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-02 13:36:53 +0000
committerAvatar Piotr Jaroszyński <peper@gentoo.org> 2007-05-02 13:36:53 +0000
commite2f024b0052951901595dfea192eb9ad519b10a8 (patch)
tree5ae8272d76888018a2a89b48103f9aa68111819a
parentfbe3f4eb235c2f8d3bb8bed193509555d3687ca8 (diff)
downloadpaludis-e2f024b0052951901595dfea192eb9ad519b10a8.tar.gz
paludis-e2f024b0052951901595dfea192eb9ad519b10a8.tar.xz
Be more strict with dots in VersionSpec.
-rw-r--r--paludis/version_spec.cc15
-rw-r--r--paludis/version_spec_TEST.cc7
2 files changed, 21 insertions, 1 deletions
diff --git a/paludis/version_spec.cc b/paludis/version_spec.cc
index db06a73..aa36a5c 100644
--- a/paludis/version_spec.cc
+++ b/paludis/version_spec.cc
@@ -142,7 +142,7 @@ VersionSpec::VersionSpec(const std::string & text) :
_imp->parts.push_back(Part(number, number_part));
- if (p < text.length() && '.' != text.at(p))
+ if (p < text.length() && ('.' != text.at(p) || p + 1 == text.length()))
break;
++p;
@@ -283,6 +283,9 @@ VersionSpec::VersionSpec(const std::string & text) :
Log::get_instance()->message(ll_qa, lc_context) <<
"Number part '" << number_part << "' exceeds 8 digit limit";
+ /* Are we -r */
+ bool empty(number_part.empty());
+
number_part = strip_leading(number_part, "0");
if (number_part.empty())
number_part = "0";
@@ -292,6 +295,16 @@ VersionSpec::VersionSpec(const std::string & text) :
break;
if (text.at(p) != '.')
break;
+ else if (empty)
+ {
+ /* we don't like -r. */
+ break;
+ }
+ else if (! (p + 1 < text.length() && text.at(p + 1) >= '0' && text.at(p + 1) <= '9'))
+ {
+ /* we don't like -rN.x where x is not a digit */
+ break;
+ }
else
++p;
}
diff --git a/paludis/version_spec_TEST.cc b/paludis/version_spec_TEST.cc
index 1c0aa86..fd19318 100644
--- a/paludis/version_spec_TEST.cc
+++ b/paludis/version_spec_TEST.cc
@@ -91,6 +91,13 @@ namespace test_cases
TEST_CHECK_THROWS(VersionSpec v1("1_pre-r2b"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1_pre-r2-r2"), BadVersionSpecError);
TEST_CHECK_THROWS(VersionSpec v1("1-r2_pre"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1."), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1.1."), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1.-r"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1.-r1"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-r.0"), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1-r1."), BadVersionSpecError);
+ TEST_CHECK_THROWS(VersionSpec v1("1_p1."), BadVersionSpecError);
}
} test_version_spec_reject;