From 231127100ff8cc633863850dab628fd57ffb7edd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tommi=20My=C3=B6h=C3=A4nen?= Date: Wed, 9 Jan 2008 15:20:19 +0000 Subject: [PATCH] gst/id3demux/id3v2frames.c: Make sure the ISO 639-X language code in ID3v2 COMM frames so we don't end up with non-UT... MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Original commit message from CVS: Based on patch by: Tommi Myöhänen * gst/id3demux/id3v2frames.c: (parse_comment_frame): Make sure the ISO 639-X language code in ID3v2 COMM frames is actually valid UTF-8 (or rather: ASCII), so we don't end up with non-UTF8 strings in tags if there's garbage in the language field. Also make sure the language code is always lower case. Fixes: #508291. --- ChangeLog | 11 +++++++++++ gst/id3demux/id3v2frames.c | 14 +++++++++----- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index d3c11b9684..cbf50cedb1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-01-09 Tim-Philipp Müller + + Based on patch by: Tommi Myöhänen + + * gst/id3demux/id3v2frames.c: (parse_comment_frame): + Make sure the ISO 639-X language code in ID3v2 COMM frames + is actually valid UTF-8 (or rather: ASCII), so we don't end + up with non-UTF8 strings in tags if there's garbage in the + language field. Also make sure the language code is always + lower case. Fixes: #508291. + 2008-01-09 Stefan Kost * ChangeLog: diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c index b67f356d4d..ec06dd2484 100644 --- a/gst/id3demux/id3v2frames.c +++ b/gst/id3demux/id3v2frames.c @@ -225,10 +225,10 @@ parse_comment_frame (ID3TagsWorking * work) return FALSE; encoding = work->parse_data[0]; - language[0] = work->parse_data[1]; - language[1] = work->parse_data[2]; - language[2] = work->parse_data[3]; - language[3] = 0; + language[0] = g_ascii_tolower (work->parse_data[1]); + language[1] = g_ascii_tolower (work->parse_data[2]); + language[2] = g_ascii_tolower (work->parse_data[3]); + language[3] = '\0'; parse_split_strings (encoding, (gchar *) work->parse_data + 4, work->parse_size - 4, &fields); @@ -250,7 +250,11 @@ parse_comment_frame (ID3TagsWorking * work) sscanf (description, "c%u", &dummy) != 1) { gchar *s; - if (language[0] != '\0') { + /* must be either an ISO-639-1 or ISO-639-2 language code */ + if (language[0] != '\0' && + g_ascii_isalpha (language[0]) && + g_ascii_isalpha (language[1]) && + (g_ascii_isalpha (language[2]) || language[2] == '\0')) { s = g_strdup_printf ("%s[%s]=%s", description, language, text); } else { s = g_strdup_printf ("%s=%s", description, text);