diff --git a/ChangeLog b/ChangeLog index 1ecd01b6c..c6b0b5df1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2014-03-10 Moritz Bunkus + + * mkvextract: bug fix: during the extraction of chapters, tags or + segment info XML files with the --redirect-output parameter the + BOM (byte order mark) was written twice. + 2014-03-05 Moritz Bunkus * mkvmerge: bug fix: MPEG TS: timestamp outliers are ignored if diff --git a/src/common/xml/ebml_chapters_converter.cpp b/src/common/xml/ebml_chapters_converter.cpp index ef5e10645..10ca7ad4b 100644 --- a/src/common/xml/ebml_chapters_converter.cpp +++ b/src/common/xml/ebml_chapters_converter.cpp @@ -162,8 +162,12 @@ ebml_chapters_converter_c::write_xml(KaxChapters &chapters, ebml_chapters_converter_c converter; converter.to_xml(chapters, doc); + auto flags = pugi::format_default; + if (!out.bom_written()) + flags |= pugi::format_write_bom; + std::stringstream out_stream; - doc->save(out_stream, " ", pugi::format_default | pugi::format_write_bom); + doc->save(out_stream, " ", flags); out.puts(out_stream.str()); } diff --git a/tests/results.txt b/tests/results.txt index 8ac0d213c..7f61bae85 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -271,3 +271,4 @@ T_422ac3_rederive_track_parameters_from_bitstream:7cf40379f451c604c8b6fce1f66b52 T_423deprecated_iso639_codes:9e7d8ab790007cf4f26ea31bb5de148f-good-6dd4fb24b0c76fb411a108102145eb71-good-2f580ffb94651b8782075a35b69258f3-good-4425838d0144c380ddbf59815cf83455-good:passed:20140222-185414:0.243526271 T_424avc_recover_point_sei_before_second_field:b66042e704ced1b55a5283d4b09876de:passed:20140304-190254:1.581374408 T_425mpeg_ts_timestamp_outlier:d9c6a4a1c7e815fed80a038128899586:passed:20140305-203603:2.509694471 +T_426extract_write_bom_only_once:a9255d40de93e2731aaead0a746e582f-a9255d40de93e2731aaead0a746e582f:passed:20140310-195606:0.0 diff --git a/tests/test-426extract_write_bom_only_once.rb b/tests/test-426extract_write_bom_only_once.rb new file mode 100755 index 000000000..f11ff96fd --- /dev/null +++ b/tests/test-426extract_write_bom_only_once.rb @@ -0,0 +1,18 @@ +#!/usr/bin/ruby -w +# -*- coding: utf-8 -*- + +# T_426extract_write_bom_only_once +file = "data/mkv/complex.mkv" + +describe "mkvextract / write BOMs only once with --redirect-output" +test "extraction via shell redirection" do + extract(file, :mode => :chapters). + slice(0..-2). + join(''). + md5 +end + +test "extraction via --redirect-output" do + sys "../src/mkvextract --engage no_variable_data chapters #{file} --redirect-output #{tmp} &> /dev/null" + hash_tmp +end