[devscripts] 02/03: licensecheck: Accept all non-binary/unknown encoding files

James McCoy jamessan at debian.org
Sat Aug 1 00:46:26 UTC 2015


This is an automated email from the git hooks/post-receive script.

jamessan pushed a commit to branch master
in repository devscripts.

commit f1d45e8716c8072049248b1d9a59f05c90f9e4d5
Author: James McCoy <jamessan at debian.org>
Date:   Fri Jul 31 20:12:08 2015 -0400

    licensecheck: Accept all non-binary/unknown encoding files
    
    Rather than using a limited whitelist of mime types, accept and decode
    any file of a known encoding.  Also attempt to parse through non-decoded
    data of unknown encoding.
    
    Closes: #794282
    Signed-off-by: James McCoy <jamessan at debian.org>
---
 debian/changelog        |  4 ++++
 scripts/licensecheck.pl | 11 ++++++-----
 2 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6536846..3cbbc1a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,6 +2,10 @@ devscripts (2.15.7) UNRELEASED; urgency=medium
 
   * licensecheck:
     + Use Dpkg::IPC to run file to avoid shell injection.  (Closes: #794260)
+    + Change whitelist of mime types to greylist of encodings.  Restores
+      ability to check files with mime types like text/x-c++ and
+      application/postscript.  Thanks to Jonas Smedegaard for the patch.
+      (Closes: #794282)
 
  -- James McCoy <jamessan at debian.org>  Fri, 31 Jul 2015 19:53:04 -0400
 
diff --git a/scripts/licensecheck.pl b/scripts/licensecheck.pl
index e520a4a..047dc7f 100755
--- a/scripts/licensecheck.pl
+++ b/scripts/licensecheck.pl
@@ -329,22 +329,23 @@ while (@files) {
           nocheck => 1,
           wait_child => 1);
     my $charset ;
-    if ($mime =~ m!(?:text/[\w-]+|application/xml); charset=([\w-]+)!) {
+    if ($mime =~ m/; charset=((?!binary)(?!unknown)[\w-]+)/) {
 	$charset = $1;
     }
     else {
 	chomp $mime;
 	warn "$0 warning: cannot parse file '$file' with mime type '$mime'\n";
-	next;
+	$charset = 'maybe-binary';
     }
 
     open (my $F, '<' ,$file) or die "Unable to access $file\n";
     binmode $F, ':raw';
 
     while ( <$F>) {
-        last if ($. > $OPT{'lines'});
-        my $data = decode($charset,$_);
-        $content .= $data;
+	last if ($. > $OPT{'lines'});
+	my $data = $_;
+	$data = decode($charset, $data) if $charset ne 'maybe-binary';
+	$content .= $data;
     }
     close($F);
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/devscripts.git



More information about the devscripts-devel mailing list