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!
8 # http://www.fileformat.info/info/unicode/char/feff/index.htm
9 # http://bugzilla.wikimedia.org/show_bug.cgi?id=9954
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/ ;
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: $!";
33 if( $line =~ /$bomchar/ ) {
34 fail
"$file has a Byte Order Mark at line $.";
36 pass
"$file has no Byte Order Mark!";