[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[SCM] Debian package checker branch, master, updated. 2.5.11-45-g3483007



The following commit has been merged in the master branch:
commit 3483007f38f8c3feea45f81befb637c2d613ec33
Author: Niels Thykier <niels@thykier.net>
Date:   Fri Jan 4 13:41:20 2013 +0100

    L::Lab + lintian: Properly handle lab queries with epochs
    
    Instead of taking anything up to the first colon, only accept letters
    in the "type" part.  Additionally, have the frontend handle bad
    queries more gracefully than simply erroring out.
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/frontend/lintian b/frontend/lintian
index 5e8b158..cc5e057 100755
--- a/frontend/lintian
+++ b/frontend/lintian
@@ -1414,12 +1414,12 @@ sub handle_lab_query {
     # "britney"-like format - note this catches the old style, where only the
     # package name was specified.
     # Check if it starts with a type specifier (i.e. binary:eclipse/3.5.2-1/amd64)
-    if ($query =~ m,^([^:]+):(.*),) {
+    if ($query =~ m,^([a-z]+):(.*),i) {
         ($type, $query) = ($1, $2);
     }
     # Split on /
     ($pkg, $version, $arch) = split m,/,o, $query, 3;
-    if ($pkg =~ m|^\.{0,2}$| or $pkg =~ m,_, or
+    if ($pkg =~ m|^\.{0,2}$| or $pkg =~ m,[_:], or
           (defined $arch and $arch =~ m,/,) ) {
         # Technically, a string like "../somewhere/else",
         # "somepkg_version_arch.deb", "/somewhere/somepkg.deb" or even
@@ -1433,11 +1433,26 @@ sub handle_lab_query {
     }
 
     if (not defined $type and $pkg_mode ne 'auto') {
+        # No type specified and "auto" is not the default so we
+        # pre-append the default type.
         $query = "$pkg_mode:$query";
         $type = $pkg_mode;
+    } else {
+        # Type specified or no type and "auto" being the default.  In
+        # this case we just process the original query.
+        $query = $orig;
     }
 
-    @res = $LAB->lab_query ($query);
+    eval {
+        @res = $LAB->lab_query ($query);
+    };
+    if (my $err = $@) {
+        $err =~ s/ at .*? line \d+\s*$//;
+        warning ("Bad lab-query: $orig");
+        warning ("Error: $err");
+        $exit_code = 2;
+        return ();
+    }
 
     if (@res) {
         foreach my $p (@res) {
diff --git a/lib/Lintian/Lab.pm b/lib/Lintian/Lab.pm
index d17555f..f332c25 100644
--- a/lib/Lintian/Lab.pm
+++ b/lib/Lintian/Lab.pm
@@ -374,7 +374,7 @@ sub lab_query {
     my @result;
     my ($name, $version, $arch);
 
-    if ($query =~ s/^([^:]++)://) {
+    if ($query =~ s/^([a-z]++)://i) {
         $type = $1;
         unless (exists $SUPPORTED_TYPES{$type} or
                 exists $SUPPORTED_VIEWS{$type} or
@@ -391,10 +391,10 @@ sub lab_query {
     # arch is not supposed to have "/" => bad query.
     croak "$query_orig is not a valid Lab query"
         if defined $arch and $arch =~ m,/, ;
-    # if $name is empty/undef, "." or ".." or contains "_" it is a bad
-    # query as well.
+    # if $name is empty/undef, ".", ".." or contains "_" or ":" it is
+    # a bad query as well.
     croak "$query_orig is not a valid Lab query"
-        if not defined $name or $name =~ m|^\.?\.?$| or $name =~ m,_,;
+        if not defined $name or $name =~ m|^\.?\.?$| or $name =~ m,[_:],;
 
     # At this point we "probably" have a reasonable query.
 

-- 
Debian package checker


Reply to: