diff --git a/src/flac/main.c b/src/flac/main.c index f45488d180..bea1c286b0 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -54,6 +54,7 @@ #include "local_string_utils.h" /* for flac__strlcat() and flac__strlcpy() */ #include "utils.h" #include "vorbiscomment.h" +#include "foreign_metadata.h" #if 0 /*[JEC] was:#if HAVE_GETOPT_LONG*/ @@ -1522,9 +1523,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ } else { if(!memcmp(lookahead, "ID3", 3)) { - flac__utils_printf(stderr, 1, "ERROR: input file %s has an ID3v2 tag\n", infilename); - conditional_fclose(encode_infile); - return 1; + /* 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 */ + if(!option_values.continue_through_decode_errors) { + flac__utils_printf(stderr, 1, "ERROR: input file %s has an ID3v2 tag\n", infilename); + 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/input-id3v2.flac b/test/flac-to-flac-metadata-test-files/input-id3v2.flac new file mode 100644 index 0000000000..bae42e0bcf Binary files /dev/null and b/test/flac-to-flac-metadata-test-files/input-id3v2.flac differ diff --git a/test/test_flac.sh b/test/test_flac.sh index ba94ceeeee..2848e62ced 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -1294,6 +1294,36 @@ 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 + +if run_flac -o out.flac -f "$testdatadir/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 refrenece it's metadata to ensure the operation wa sucessfull + +if flac2flac input-id3v2.flac case04c "-F --no-padding" ; then + # Test to see if ID3v2 errors are gone + if run_flac -t "out.flac" ; then + echo "Ok, it suceeded and bad tags are gone" + else + die "ID3v2 tags still present in files" + fi +else + echo $? + die "ERROR: it should have succeeded but didn't" +fi + ############################################################################ # test limiting minimum bitrate ############################################################################