From 5ca7684b7da50803376c2273f6070af84f64ffdc Mon Sep 17 00:00:00 2001 From: Damian Ziobro Date: Wed, 28 May 2014 09:18:49 +0100 Subject: [PATCH] hlsdemux: Make parsing of "-quoted key URIs more resilient https://bugzilla.gnome.org/show_bug.cgi?id=730830 --- ext/hls/m3u8.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/ext/hls/m3u8.c b/ext/hls/m3u8.c index 618d52d1b0..d66da2d47d 100644 --- a/ext/hls/m3u8.c +++ b/ext/hls/m3u8.c @@ -479,13 +479,25 @@ gst_m3u8_update (GstM3U8 * self, gchar * data, gboolean * updated) if (g_str_equal (a, "URI")) { gchar *key = g_strdup (v); gchar *keyp = key; - int len = strlen (key); + gchar *key_ret; - /* handle the \"key\" case */ - if (key[len - 1] == '"') - key[len - 1] = '\0'; - if (key[0] == '"') - key += 1; + /* handle the \"key\" case * + * there are sometimes situations where we have white signs + * before or after \" sign of URL therefore we are using for loops + * in order to remove first and last \" sign from decryption key URI */ + key_ret = strchr (key, '"'); + if (key_ret != NULL) { + /* found initialization quotation mark key URI */ + key = key_ret + 1; + key_ret = strchr (key, '"'); + if (key_ret != NULL) { + /* found finalizing quotation mark inside key URI */ + key_ret[0] = '\0'; + } else { + GST_WARNING + ("Decryption key URL parsing - cannot find finalizing quotation mark"); + } + } self->key = uri_join (self->base_uri ? self->base_uri : self->uri, key);