Commit 18a24729 authored by Magali Ruffier's avatar Magali Ruffier
Browse files

only allow integers

parent 2de07724
......@@ -153,7 +153,7 @@ sub fetch_by_stable_id {
# a version number in the stable_id
if(!defined($arch_id)) {
my $vindex = rindex($stable_id, '.');
if ($vindex !~ /[0-9]{1,5}/) { return $arch_id; }
if ($vindex !~ /^[0-9]{1,5}$/) { return $arch_id; }
$arch_id = $self->fetch_by_stable_id_version(substr($stable_id,0,$vindex),
substr($stable_id,$vindex+1),
@_);
......@@ -260,7 +260,7 @@ sub fetch_by_stable_id_version {
-adaptor => $self
);
if ($version !~ /[0-9]{1,5}/) {
if ($version !~ /^[0-9]{1,5}$/) {
throw("$version is not valid, should be a small int");
}
......
......@@ -59,6 +59,7 @@ is( $asi->release, 2, "T1 is from release 2");
throws_ok { $asia->fetch_by_stable_id_version("T1", 'invalid_version') } qr/is not valid, should be a small int/, "version must be an integer";
warning { throws_ok { $asia->fetch_by_stable_id("T1.invalid_version") } qr/is not valid, should be a small int/, "Stable ID must have an integer as version" };
throws_ok { $asia->fetch_by_stable_id_version("T1", "invalid12345_version") } qr/is not valid, should be a small int/, "version must be only an integer";
#
......
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