]> git.donarmstrong.com Git - perltidy.git/commitdiff
remove BOM if any
authorSteve Hancock <perltidy@users.sourceforge.net>
Sun, 22 Mar 2020 01:55:20 +0000 (18:55 -0700)
committerSteve Hancock <perltidy@users.sourceforge.net>
Sun, 22 Mar 2020 01:55:20 +0000 (18:55 -0700)
lib/Perl/Tidy.pm

index d9433dffe51db8196df8ab2f1aec0bc38d505c7c..9cc42f5690dae5858a6bb7ad8fd631981281c149 100644 (file)
@@ -992,6 +992,11 @@ EOM
         # we must not treat it as encoded data.
         my $is_encoded_data = $encoding_in ? 'utf8' : "";
 
+        # Delete any Byte Order Mark (BOM), which can cause trouble
+        if ($is_encoded_data) {
+           $buf =~ s/^\x{FEFF}//;
+        }
+
         # MD5 sum of input file is evaluated before any prefilter
         if ( $rOpts->{'assert-tidy'} || $rOpts->{'assert-untidy'} ) {
             $digest_input = $md5_hex->($buf);