From 370a6a7162c06ef30219968faf44fd50488155d3 Mon Sep 17 00:00:00 2001 From: OwenCochell Date: Sun, 9 Nov 2025 00:20:29 -0600 Subject: [PATCH 1/7] Skips over ID3v2 tags when decode through errors is enabled --- src/flac/main.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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; From 583b3f288dfc8b5211ad634caeedefa4392ac6a9 Mon Sep 17 00:00:00 2001 From: OwenCochell Date: Sun, 9 Nov 2025 00:21:03 -0600 Subject: [PATCH 2/7] Added ID3v2 tag to input-VA.flac for testing --- .../input-id3v2.flac | Bin 0 -> 2176 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 test/flac-to-flac-metadata-test-files/input-id3v2.flac 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 0000000000000000000000000000000000000000..bae42e0bcf81d37d50ff71655c5ae3d3f408db07 GIT binary patch literal 2176 zcmeZtF=l1}0^V?Ee_vl9gA>F9f|AtY5(sOQ91Vfd5Eu=C(GVC7fuR=yX+DY0KvydX zF$e)EJ_ZH>t|Lw#7#PHUl>EO^T({MuH&FY@`iLpUNh}Nurxk!|ic-^3i&FEFQx$SD zliYk9ofQoA4E2l^j0_CS3@i*x*??+5>VjMYd>kX)9XNXQG;R%2hg6xqLR$w5?e!dAiE^9Bq!C@ wsEL7rB`q;K_5Y7Z35IN-I1mVQ{r^!Z!N~Ic6NLZ$T!^DPgh?wBe>>to01TB Date: Sun, 9 Nov 2025 00:21:14 -0600 Subject: [PATCH 3/7] Added test for skipping ID3v2 tags --- test/test_flac.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/test/test_flac.sh b/test/test_flac.sh index ba94ceeeee..78248967d4 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -38,7 +38,7 @@ run_flac () echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* 4>>test_flac.valgrind.log else - flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* + flac${EXE} --no-error-on-compression-fail $* fi } @@ -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 ############################################################################ From 5211b16cf91d432ab17140c23401c0b52daf0791 Mon Sep 17 00:00:00 2001 From: OwenCochell Date: Sun, 9 Nov 2025 00:44:34 -0600 Subject: [PATCH 4/7] Re-enabled silent mode in flac tests --- test/test_flac.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_flac.sh b/test/test_flac.sh index 78248967d4..2848e62ced 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -38,7 +38,7 @@ run_flac () echo "valgrind --leak-check=yes --show-reachable=yes --num-callers=50 flac $*" >>test_flac.valgrind.log valgrind --leak-check=yes --show-reachable=yes --num-callers=50 --log-fd=4 flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* 4>>test_flac.valgrind.log else - flac${EXE} --no-error-on-compression-fail $* + flac${EXE} $TOTALLY_SILENT --no-error-on-compression-fail $* fi } From 61d5a33fd8b5a7581c66e4dcedcbfbc64e8471c6 Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Sun, 19 Jul 2026 11:02:50 +0200 Subject: [PATCH 5/7] Trim down test file to bare minimum --- src/flac/main.c | 3 +-- .../id3v2.bin | Bin 0 -> 32 bytes .../input-id3v2.flac | Bin 2176 -> 0 bytes test/test_flac.sh | 19 ++++++++++-------- 4 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 test/flac-to-flac-metadata-test-files/id3v2.bin delete mode 100644 test/flac-to-flac-metadata-test-files/input-id3v2.flac diff --git a/src/flac/main.c b/src/flac/main.c index 9b999d8140..fd99a30427 100644 --- a/src/flac/main.c +++ b/src/flac/main.c @@ -54,7 +54,6 @@ #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*/ @@ -1525,8 +1524,8 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_ 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); 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; } 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 0000000000000000000000000000000000000000..e69db5461572f19907d17711ad59695f5a44ebe1 GIT binary patch literal 32 ecmeZtF=l1}0WoKPUtb{23Fa{{l%y7y0GR+g-viG8 literal 0 HcmV?d00001 diff --git a/test/flac-to-flac-metadata-test-files/input-id3v2.flac b/test/flac-to-flac-metadata-test-files/input-id3v2.flac deleted file mode 100644 index bae42e0bcf81d37d50ff71655c5ae3d3f408db07..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2176 zcmeZtF=l1}0^V?Ee_vl9gA>F9f|AtY5(sOQ91Vfd5Eu=C(GVC7fuR=yX+DY0KvydX zF$e)EJ_ZH>t|Lw#7#PHUl>EO^T({MuH&FY@`iLpUNh}Nurxk!|ic-^3i&FEFQx$SD zliYk9ofQoA4E2l^j0_CS3@i*x*??+5>VjMYd>kX)9XNXQG;R%2hg6xqLR$w5?e!dAiE^9Bq!C@ wsEL7rB`q;K_5Y7Z35IN-I1mVQ{r^!Z!N~Ic6NLZ$T!^DPgh?wBe>>to01TB "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" @@ -1316,15 +1320,14 @@ 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 +# 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 flac2flac input-id3v2.flac case04c "-F --no-padding" ; then +if run_flac -o out.flac --decode-through-errors -f "input-id3v2.flac" ; 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 + $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" From ba3386854e04ff322b36a57fba5bf583f830d02d Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Sun, 19 Jul 2026 11:08:56 +0200 Subject: [PATCH 6/7] Clean up afterwards --- test/test_flac.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/test_flac.sh b/test/test_flac.sh index 574419066b..1ff4226b79 100755 --- a/test/test_flac.sh +++ b/test/test_flac.sh @@ -1333,6 +1333,8 @@ else die "ERROR: it should have succeeded but didn't" fi +rm -f input-id3v2.flac out.flac + ############################################################################ # test limiting minimum bitrate ############################################################################ From f647fc9587eff2a1674a84705fc62611fad1b72d Mon Sep 17 00:00:00 2001 From: Martijn van Beurden Date: Sun, 19 Jul 2026 11:30:40 +0200 Subject: [PATCH 7/7] Update Makefile.am --- test/flac-to-flac-metadata-test-files/Makefile.am | 1 + 1 file changed, 1 insertion(+) 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 \