summaryrefslogtreecommitdiffstats
path: root/gst/id3demux
diff options
context:
space:
mode:
authorTommi Myöhänen <ext-tommi.myohanen@nokia.com>2008-01-09 15:20:19 +0000
committerTim-Philipp Müller <tim@centricular.net>2008-01-09 15:20:19 +0000
commit231127100ff8cc633863850dab628fd57ffb7edd (patch)
tree6a13c85e2d6d38b98a4564a311b922314a2624fe /gst/id3demux
parent90dd96debcc14895ede8af93e058625712f3d71c (diff)
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...
Original commit message from CVS: Based on patch by: Tommi Myöhänen <ext-tommi.myohanen nokia com> * 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.
Diffstat (limited to 'gst/id3demux')
-rw-r--r--gst/id3demux/id3v2frames.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/gst/id3demux/id3v2frames.c b/gst/id3demux/id3v2frames.c
index b67f356d..ec06dd24 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);