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

[SCM] Debian package checker branch, master, updated. 2.5.6-40-g35bfafa



The following commit has been merged in the master branch:
commit 2acf2fa05ff65ae5a7318d501471b7fe513043f7
Author: Niels Thykier <niels@thykier.net>
Date:   Mon Apr 2 14:40:47 2012 +0200

    L::Output: Replace non-printables with "?" in the output
    
    Signed-off-by: Niels Thykier <niels@thykier.net>

diff --git a/debian/changelog b/debian/changelog
index 5414e18..9d1a838 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -81,6 +81,8 @@ lintian (2.5.7) UNRELEASED; urgency=low
     + [NT] Lazily load data files.
     + [NT] Allow pre-process sub to alter existing value for a key
       by passing the previous value as third argument.
+  * lib/Lintian/Output{,/*}.pm:
+    + [NT] Replace non-printables with "?" in output.
   * lib/Lintian/Profile.pm:
     + [NT] Normalize profile name and replace "parents" with
       "profile_list".  The latter also includes the current profile
diff --git a/lib/Lintian/Output.pm b/lib/Lintian/Output.pm
index c68eb0a..64b2ae4 100644
--- a/lib/Lintian/Output.pm
+++ b/lib/Lintian/Output.pm
@@ -285,7 +285,7 @@ Lintian::Tags::tag().
 
 sub print_tag {
     my ($self, $pkg_info, $tag_info, $information, $override) = @_;
-    $information = ' ' . $information if $information ne '';
+    $information = ' ' . $self->_quote_print ($information) if $information ne '';
     my $code = $tag_info->code;
     my $tag_color = $self->{colors}{$code};
     my $fpkg_info = $self->_format_pkg_info ($pkg_info, $tag_info, $override);
@@ -306,7 +306,9 @@ sub print_tag {
     }
 
     if ($override && @{ $override->comments }) {
-        $self->msg(@{ $override->comments } );
+        foreach my $c (@{ $override->comments }) {
+            $self->msg( $self->_quote_print ($c) );
+        }
     }
 
     $self->_print('', $fpkg_info, "$tag$information");
@@ -456,6 +458,20 @@ sub _do_color {
                 && -t $self->stdout));
 }
 
+=item C<_quote_print($string)>
+
+Called to quote a string.  By default it will replace all
+non-printables with "?".  Sub-classes can override it if
+they allow non-ascii printables etc.
+
+=cut
+
+sub _quote_print {
+    my ($self, $string) = @_;
+    $string =~ s/[^[:print:]]/?/go;
+    return $string;
+}
+
 =back
 
 =head1 CLASS METHODS
diff --git a/lib/Lintian/Output/ColonSeparated.pm b/lib/Lintian/Output/ColonSeparated.pm
index 7dc1ac1..cfe95a8 100644
--- a/lib/Lintian/Output/ColonSeparated.pm
+++ b/lib/Lintian/Output/ColonSeparated.pm
@@ -31,7 +31,7 @@ sub print_tag {
     my $odata = '';
     if ($override) {
         $odata = $override->tag;
-        $odata .= ' ' . $override->extra if $override->extra;
+        $odata .= ' ' . $self->_quote_print ($override->extra) if $override->extra;
     }
 
     $self->issued_tag($tag_info->tag);
@@ -44,7 +44,7 @@ sub print_tag {
         (defined($override) ? 'O' : ''),
         @{$pkg_info}{'package','version','arch','type'},
         $tag_info->tag,
-        $information,
+        $self->_quote_print ($information),
         $odata,
         );
 }
diff --git a/lib/Lintian/Output/LetterQualifier.pm b/lib/Lintian/Output/LetterQualifier.pm
index e1f46cb..ebbd9e4 100644
--- a/lib/Lintian/Output/LetterQualifier.pm
+++ b/lib/Lintian/Output/LetterQualifier.pm
@@ -118,7 +118,7 @@ sub print_tag {
 
     my $tag = $tag_info->tag;
 
-    $information = ' ' . $information if $information ne '';
+    $information = ' ' . $self->_quote_print ($information) if $information ne '';
 
     if ($self->_do_color) {
         my $color = $self->colors->{$sev}{$cer};
diff --git a/lib/Lintian/Output/XML.pm b/lib/Lintian/Output/XML.pm
index 5ee4de0..35dc06e 100644
--- a/lib/Lintian/Output/XML.pm
+++ b/lib/Lintian/Output/XML.pm
@@ -44,7 +44,7 @@ sub print_tag {
                  [ certainty => $tag_info->certainty ],
                  [ flags     => $flags ],
                  [ name      => $tag_info->tag ]);
-    print { $self->stdout } $self->_make_xml_tag('tag', \@attrs, $information, $comment), "\n";
+    print { $self->stdout } $self->_make_xml_tag('tag', \@attrs, $self->_quote_print ($information), $comment), "\n";
 }
 
 sub print_start_pkg {

-- 
Debian package checker


Reply to: