diff options
author | Edward Hervey <bilboed@bilboed.com> | 2010-09-24 15:19:15 +0200 |
---|---|---|
committer | Edward Hervey <bilboed@bilboed.com> | 2010-09-24 15:27:24 +0200 |
commit | 87a9d7f679b60af713ad9318125094a92fa487ab (patch) | |
tree | 122e1c67f07924d18176ef8d20394be649fc0cef /gst/id3demux | |
parent | c6c941f315489f528c690ca700e75d2325e6d046 (diff) |
id3demux: Sanitize id3 frame names
This is similar to what is done in qtdemux. Avoids providing invalid
structure/tags names
Diffstat (limited to 'gst/id3demux')
-rw-r--r-- | gst/id3demux/id3tags.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/gst/id3demux/id3tags.c b/gst/id3demux/id3tags.c index 68a88f82e..709cda87d 100644 --- a/gst/id3demux/id3tags.c +++ b/gst/id3demux/id3tags.c @@ -340,6 +340,7 @@ id3demux_add_id3v2_frame_blob_to_taglist (ID3TagsWorking * work, guint size) guint8 *frame_data; gchar *media_type; guint frame_size, header_size; + guint i; switch (ID3V2_VER_MAJOR (work->hdr.version)) { case 1: @@ -360,6 +361,12 @@ id3demux_add_id3v2_frame_blob_to_taglist (ID3TagsWorking * work, guint size) blob = gst_buffer_new_and_alloc (frame_size); memcpy (GST_BUFFER_DATA (blob), frame_data, frame_size); + /* Sanitize frame id */ + for (i = 0; i < 4; i++) { + if (!g_ascii_isalnum (frame_data[i])) + frame_data[i] = '_'; + } + media_type = g_strdup_printf ("application/x-gst-id3v2-%c%c%c%c-frame", g_ascii_tolower (frame_data[0]), g_ascii_tolower (frame_data[1]), g_ascii_tolower (frame_data[2]), g_ascii_tolower (frame_data[3])); @@ -418,6 +425,7 @@ id3demux_id3v2_frames_to_tag_list (ID3TagsWorking * work, guint size) guint16 frame_flags = 0x0; gboolean obsolete_id = FALSE; gboolean read_synch_size = TRUE; + guint i; /* Read the header */ switch (ID3V2_VER_MAJOR (work->hdr.version)) { @@ -467,6 +475,22 @@ id3demux_id3v2_frames_to_tag_list (ID3TagsWorking * work, guint size) if (frame_size > work->hdr.frame_data_size || strcmp (frame_id, "") == 0) break; /* No more frames to read */ + /* Sanitize frame id */ + switch (ID3V2_VER_MAJOR (work->hdr.version)) { + case 0: + case 1: + case 2: + for (i = 0; i < 3; i++) { + if (!g_ascii_isalnum (frame_id[i])) + frame_id[i] = '_'; + } + break; + default: + for (i = 0; i < 4; i++) { + if (!g_ascii_isalnum (frame_id[i])) + frame_id[i] = '_'; + } + } #if 1 GST_LOG ("Frame @ %ld (0x%02lx) id %s size %u, next=%ld (0x%02lx) obsolete=%d", |