Skip Menu |
 

This queue is for tickets about the File-MMagic CPAN distribution.

Report information
The Basics
Id: 13535
Status: resolved
Priority: 0/
Queue: File-MMagic

People
Owner: Nobody in particular
Requestors: dakkar [...] thenautilus.net
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.22
Fixed in: (no value)

Attachments


Subject: check_binary returns true for text files contaning square brackets
Download (untitled) / with headers
text/plain 378b
The call to the C<tr> operator in the C<check_binary> function uses what looks like a recexp character class, but C<tr> takes a just list of characters. So the C<[]> square brackets will be counted as "binary" characters, and a file contaning enough of them will be incorrectly marked as "binary". It happened to me an this very short template (TT2): [% code %] [% name %]
Download File::MMagic.patch
text/x-diff 858b
--- /Users/dakkar/Library/Perl/File/MMagic.pm 2004-03-15 09:23:04.000000000 +0100 +++ MMagic.pm 2005-07-04 13:10:00.000000000 +0200 @@ -727,11 +727,11 @@ my ($data) = @_; my $len = length($data); if ($allowEightbit) { - my $count = ($data =~ tr/[\x00-\x08\x0b-\x0c\x0e-\x1a\x1c-\x1f]//); # exclude TAB, ESC, nl, cr + my $count = ($data =~ tr/\x00-\x08\x0b-\x0c\x0e-\x1a\x1c-\x1f//); # exclude TAB, ESC, nl, cr return 1 if ($len <= 0); # no contents return 1 if (($count/$len) > 0.1); # binary } else { - my $count = ($data =~ tr/[\x00-\x08\x0b-\x0c\x0e-\x1a\x1c-\x1f\x80-\xff]//); # exclude TAB, ESC, nl, cr + my $count = ($data =~ tr/\x00-\x08\x0b-\x0c\x0e-\x1a\x1c-\x1f\x80-\xff//); # exclude TAB, ESC, nl, cr return 1 if ($len <= 0); # no contents return 1 if (($count/$len) > 0.3); # binary }


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.