[python-debian/master] Disallow ':' in upstream version if there is no epoch
John Wright
john at johnwright.org
Wed Mar 30 07:51:46 UTC 2011
debian_support.BaseVersion previously allowed bogus version strings to
slip by, such as 'a1:1.8.8-070403-1~priv1'.
Original patch by Steve Kowalik <stevenk at debian.org>.
Closes: #619997
---
debian/changelog | 8 ++++++++
lib/debian/changelog.py | 2 ++
lib/debian/debian_support.py | 4 ++++
tests/test_changelog.py | 2 ++
tests/test_debian_support.py | 2 ++
5 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 0292524..d6643c1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+python-debian (0.1.19) UNRELEASED; urgency=low
+
+ * debian_support.BaseVersion: Disallow ':' in upstream version if
+ there is no epoch. Original patch by Steve Kowalik.
+ (Closes: #619997)
+
+ -- John Wright <jsw at debian.org> Wed, 30 Mar 2011 00:47:04 -0700
+
python-debian (0.1.18) unstable; urgency=low
* Support installation together with older versions of python-apt.
diff --git a/lib/debian/changelog.py b/lib/debian/changelog.py
index 6b52aa1..3786e7f 100644
--- a/lib/debian/changelog.py
+++ b/lib/debian/changelog.py
@@ -56,6 +56,8 @@ class VersionError(StandardError):
def __str__(self):
return "Could not parse version: "+self._version
+# TODO(jsw): Remove this in favor of using debian_support.Version directly. I
+# don't think we gain anything by using this empty subclass.
class Version(debian_support.Version):
"""Represents a version of a Debian package."""
# debian_support.Version now has all the functionality we need
diff --git a/lib/debian/debian_support.py b/lib/debian/debian_support.py
index b2bcca9..2cec940 100644
--- a/lib/debian/debian_support.py
+++ b/lib/debian/debian_support.py
@@ -94,6 +94,10 @@ class BaseVersion(object):
m = self.re_valid_version.match(version)
if not m:
raise ValueError("Invalid version string %r" % version)
+ # If there no epoch ("1:..."), then the upstream version can not
+ # contain a :.
+ if (m.group("epoch") is None and ":" in m.group("upstream_version")):
+ raise ValueError("Invalid version string %r" % version)
self.__full_version = version
self.__epoch = m.group("epoch")
diff --git a/tests/test_changelog.py b/tests/test_changelog.py
index 33c017f..92376f2 100755
--- a/tests/test_changelog.py
+++ b/tests/test_changelog.py
@@ -202,6 +202,8 @@ class VersionTests(unittest.TestCase):
self._test_version('2:1.0.4+svn26-1ubuntu1', '2', '1.0.4+svn26',
'1ubuntu1')
self._test_version('2:1.0.4~rc2-1', '2', '1.0.4~rc2', '1')
+ self.assertRaises(
+ ValueError, changelog.Version, 'a1:1.8.8-070403-1~priv1')
def test_version_updating(self):
v = changelog.Version('1:1.4.1-1')
diff --git a/tests/test_debian_support.py b/tests/test_debian_support.py
index 51a2e3c..45f304b 100755
--- a/tests/test_debian_support.py
+++ b/tests/test_debian_support.py
@@ -72,6 +72,8 @@ class VersionTests(unittest.TestCase):
self._test_version('2:1.0.4+svn26-1ubuntu1', '2', '1.0.4+svn26',
'1ubuntu1')
self._test_version('2:1.0.4~rc2-1', '2', '1.0.4~rc2', '1')
+ self.assertRaises(
+ ValueError, changelog.Version, 'a1:1.8.8-070403-1~priv1')
def test_version_updating(self):
if debian_support._have_apt_pkg:
--
1.7.1
More information about the pkg-python-debian-commits
mailing list