From d63e8f150a8b8a8eacb60028afaa03502bf49574 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 26 Dec 2010 11:25:20 +0100 Subject: [PATCH] Ignore errors regarding invalid UTF-8 strings in Matroska files instead of erroring out --- ChangeLog | 5 +++++ src/common/ebml.cpp | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 427b9d979..16d87fbbb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2010-12-26 Moritz Bunkus + * mkvmerge: enhancement: If mkvmerge encounters invalid UTF-8 + strings in Matroska files then those strings will simply be cut + short. Before mkvmerge was exiting with an error ("Invalid UTF-8 + sequence encountered"). + * all: new feature: Added online update checks. The command line tools know a new parameter "--check-for-updates". mmg has a new menu entry ("Help" -> "Check for updates") and checks diff --git a/src/common/ebml.cpp b/src/common/ebml.cpp index 68c5223a7..3a69b59ef 100644 --- a/src/common/ebml.cpp +++ b/src/common/ebml.cpp @@ -97,15 +97,15 @@ cstrutf8_to_UTFstring(const std::string &c) { for (src = 0; src < slen; dlen++) { clen = utf8_byte_length(c[src]); if (clen < 0) - mxerror(Y("cstrutf8_to_UTFstring: Invalid UTF-8 sequence encountered. Please contact moritz@bunkus.org and request that he implements a better UTF-8 parser.")); + return u; src += clen; } new_string = (wchar_t *)safemalloc((dlen + 1) * sizeof(wchar_t)); for (src = 0, dst = 0; src < slen; dst++) { clen = utf8_byte_length(c[src]); - if ((src + clen) > slen) - mxerror(Y("cstrutf8_to_UTFstring: Invalid UTF-8 sequence encountered. Please contact moritz@bunkus.org and request that he implements a better UTF-8 parser.")); + if ((clen < 0) || ((src + clen) > slen)) + break; if (clen == 1) new_string[dst] = c[src];