Cleanup some docs :)
[mediawiki.git] / t / maint / bom.t
blobb5e6ae986427f6e8ef28f82d09eaf48937a23ed6
1 #!/usr/bin/env perl
3 # This test detect Byte Order Mark (BOM). The char is sometime included at the
4 # top of files by some text editors to mark them as being UTF-8 encoded.
5 # They are not stripped by php 5.x and appear at the beginning of our content,
6 # You want them removed!
7 # See:
8 # http://www.fileformat.info/info/unicode/char/feff/index.htm
9 # http://bugzilla.wikimedia.org/show_bug.cgi?id=9954
11 use strict;
12 use warnings;
14 use Test::More;
16 use File::Find;
18 # Files for wich we want to check the BOM char ( 0xFE 0XFF )
19 my $ext = qr/(?:php|inc)/x ;
21 my $bomchar = qr/\xef\xbb\xbf/ ;
23 my @files;
25 find( sub{ push @files, $File::Find::name if -f && /\.$ext$/ }, '.' );
27 # Register our files with the test system
28 plan tests => scalar @files ;
30 for my $file (@files) {
31 open my $fh, "<", $file or die "Couln't open $file: $!";
32 my $line = <$fh>;
33 if( $line =~ /$bomchar/ ) {
34 fail "$file has a Byte Order Mark at line $.";
35 } else {
36 pass "$file has no Byte Order Mark!";