diff --git a/src/flac/main.c b/src/flac/main.c index 62f8d26199..fd99a30427 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -1522,9 +1522,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ } else { if(!memcmp(lookahead, "ID3", 3)) { + /* we need to use an internal if to skip the other else if conditions */ + /* this will assume the type based upon file extension when ID3v2 tags are present */ flac__utils_printf(stderr, 1, "ERROR: input file %s has an ID3v2 tag\n", infilename); - conditional_fclose(encode_infile); - return 1; + if(!option_values.continue_through_decode_errors) { + conditional_fclose(encode_infile); + return 1; + } } else if(!memcmp(lookahead, "RIFF", 4) && !memcmp(lookahead+8, "WAVE", 4)) input_format = FORMAT_WAVE; diff --git a/test/flac-to-flac-metadata-test-files/Makefile.am b/test/flac-to-flac-metadata-test-files/Makefile.am index c1a787804a..fdf504136f 100644 --- a/test/flac-to-flac-metadata-test-files/Makefile.am +++ b/test/flac-to-flac-metadata-test-files/Makefile.am @@ -34,6 +34,7 @@ EXTRA_DIST = \ case04c-expect.meta \ case04d-expect.meta \ case04e-expect.meta \ + id3v2.bin \ input-SCPAP.flac \ input-SCVA.flac \ input-SCVAUP.flac \ diff --git a/test/flac-to-flac-metadata-test-files/id3v2.bin b/test/flac-to-flac-metadata-test-files/id3v2.bin new file mode 100644 index 0000000000..e69db54615 Binary files /dev/null and b/test/flac-to-flac-metadata-test-files/id3v2.bin differ diff --git a/test/test_flac.sh b/test/test_flac.sh index 63693e53c2..1ff4226b79 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -1300,6 +1300,41 @@ flac2flac input-SCVA.flac case04e "--no-padding -S 5x" # case 04f: on file with SEEKTABLE block and size-changing option specified, drop existing SEEKTABLE, new SEEKTABLE with default points #(already covered by case03c) +############################################################################ +# test skip ID3v2 tags +############################################################################ + +# Try to work with a flac file that has ID3v2 tag +# without decoding through errors + +echo $ECHO_N "Testing re-encoding of FLAC with ID3v2... " $ECHO_C + +cat "$testdatadir/id3v2.bin" "$testdatadir/input-VA.flac" > "input-id3v2.flac" + +if run_flac -o out.flac -f "input-id3v2.flac" ; then + die "ERROR: it should have failed but didn't" +else + echo "OK, it failed as it should" +fi + +# Decode though errors to seek past IDv3 tag +# and make sure the file metadata matches +# We just added an ID3v2 tag to input-VA.flac, +# So we compare to input file to ensure the operation was sucessfull + +echo $ECHO_N "Testing re-encoding of FLAC with ID3v2 with --decode-through-errors... " $ECHO_C + +if run_flac -o out.flac --decode-through-errors -f "input-id3v2.flac" ; then + # Test to see if ID3v2 errors are gone + $CMP "$testdatadir/input-VA.flac" out.flac || die "ERROR: ID3v2 tags still present in file" + echo "OK, it succeeded and ID3v2 is gone" +else + echo $? + die "ERROR: it should have succeeded but didn't" +fi + +rm -f input-id3v2.flac out.flac + ############################################################################ # test limiting minimum bitrate ############################################################################