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
17 use File
::Slurp qw
< slurp
>;
19 # Files for wich we want to check the BOM char ( 0xFE 0XFF )
20 my $ext = qr/(?:php|inc)/x ;
22 my $bomchar = qr/\xef\xbb\xbf/ ;
27 find
( sub{ push @files, $File::Find
::name
if -f
&& /\.$ext$/ }, '.' );
29 # Register our files with the test system
30 plan tests
=> scalar @files ;
32 for my $file (@files) {
33 my $content = slurp
$file ;
34 if( $content =~ /$bomchar/ ) {
35 ok
0 => "$file got a Byte Order Mark";
37 ok
1 => "$file BOM less";