Commit ef79ea33 authored by Frédéric Buclin's avatar Frédéric Buclin

Bug 938300: vers_cmp() incorrectly compares module versions

r=sgreen a=justdave
parent 7f666621
......@@ -14,6 +14,7 @@ package Bugzilla::Install::Requirements;
# MUST NOT "use."
use strict;
use version;
use Bugzilla::Constants;
use Bugzilla::Install::Util qw(vers_cmp install_string bin_loc
......@@ -199,7 +200,9 @@ sub OPTIONAL_MODULES {
package => 'Chart',
module => 'Chart::Lines',
# Versions below 2.1 cannot be detected accurately.
version => '2.1',
# There is no 2.1.0 release (it was 2.1), but .0 is required to fix
# https://rt.cpan.org/Public/Bug/Display.html?id=28218.
version => '2.1.0',
feature => [qw(new_charts old_charts)],
},
{
......@@ -665,8 +668,8 @@ sub check_graphviz {
return $return;
}
# This was originally clipped from the libnet Makefile.PL, adapted here to
# use the below vers_cmp routine for accurate version checking.
# This was originally clipped from the libnet Makefile.PL, adapted here for
# accurate version checking.
sub have_vers {
my ($params, $output) = @_;
my $module = $params->{module};
......@@ -691,21 +694,17 @@ sub have_vers {
if ($@) {
no strict 'refs';
$vnum = ${"${module}::VERSION"};
}
$vnum ||= -1;
# CGI's versioning scheme went 2.75, 2.751, 2.752, 2.753, 2.76
# That breaks the standard version tests, so we need to manually correct
# the version
if ($module eq 'CGI' && $vnum =~ /(2\.7\d)(\d+)/) {
$vnum = $1 . "." . $2;
}
# CPAN did a similar thing, where it has versions like 1.9304.
if ($module eq 'CPAN' and $vnum =~ /^(\d\.\d{2})\d{2}$/) {
# If we come here, then the version is not a valid one.
# We try to sanitize it.
if ($vnum =~ /^((\d+)(\.\d+)*)/) {
$vnum = $1;
}
}
$vnum ||= -1;
my $vok = (vers_cmp($vnum,$wanted) > -1);
# Must do a string comparison as $vnum may be of the form 5.10.1.
my $vok = ($vnum ne '-1' && version->new($vnum) >= version->new($wanted)) ? 1 : 0;
my $blacklisted;
if ($vok && $params->{blacklist}) {
$blacklisted = grep($vnum =~ /$_/, @{$params->{blacklist}});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment