[SCM] Debian package checker branch, master, updated. 2.5.3-34-g40c69e3
The following commit has been merged in the master branch:
commit 40c69e33e8c1f8d16d2cc8823d55eb5e71c27976
Author: Jakub Wilk <jwilk@debian.org>
Date: Wed Sep 28 13:38:05 2011 +0200
Explicitly check files not encoded using ISO-2022
Acked-by: Niels Thykier <niels@thykier.net>
diff --git a/debian/changelog b/debian/changelog
index 2dcac3d..c765d25 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -48,6 +48,8 @@ lintian (2.5.4) UNRELEASED; urgency=low
This could cause the parser to eat the first part of the value,
if it contained a colon and there was no space before the value.
Thanks to Pino Toscano for reporting the issue.
+ + [JW] Explicitly check that files are not encoded using ISO-2022,
+ when they should be encoded with UTF-8. (Closes: #643009)
* reporting/*:
+ [NT] Recognise and display pedantic tags.
diff --git a/lib/Util.pm b/lib/Util.pm
index 2d53674..2fcf7d8 100644
--- a/lib/Util.pm
+++ b/lib/Util.pm
@@ -49,6 +49,7 @@ BEGIN {
resolve_pkg_path);
}
+use Encode ();
use FileHandle;
use Lintian::Command qw(spawn);
use Lintian::Output qw(string);
@@ -241,20 +242,26 @@ sub file_is_encoded_in_non_utf8 {
my ($file, $type, $pkg) = @_;
my $non_utf8 = 0;
- open (ICONV, '-|', "env LC_ALL=C iconv -f utf8 -t utf8 \Q$file\E 2>&1")
+ open (ICONV, '<', $file)
or fail("failure while checking encoding of $file for $type package $pkg");
- my $line = 1;
+ my $line = 0;
while (<ICONV>) {
- if (m/iconv: illegal input sequence at position \d+$/) {
- $non_utf8 = 1;
+ if (m,\e[-!"\$%()*+./],) {
+ # ISO-2022
+ $line = $.;
+ last;
+ }
+ eval {
+ $_ = Encode::decode('UTF-8', $_, Encode::FB_CROAK);
+ };
+ if ($@) {
+ $line = $.;
last;
}
- $line++
}
close ICONV;
- return $line if $non_utf8;
- return 0;
+ return $line;
}
# Just like system, except cleanses the environment first to avoid any strange
--
Debian package checker
Reply to: