[gst-cvs] gst-plugins-good: multipartdemux: improve header mime-type parsing
Wim Taymans
wtay at kemper.freedesktop.org
Tue Feb 16 12:11:41 PST 2010
Module: gst-plugins-good
Branch: master
Commit: 6a877b2e6daae21772768d1973fa801143d312e6
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=6a877b2e6daae21772768d1973fa801143d312e6
Author: Anders Skargren <anders.skargren at axis.com>
Date: Tue Feb 16 21:05:24 2010 +0100
multipartdemux: improve header mime-type parsing
Make the handing of the mime type within the "boundary" a bit less naive.
The standard for MIME allows parameters to follow the "type" / "subtype"
clause separated from the mime type by ';'.
Modifies the multipartdemuxer's header parsing so it doesnt assume
the whole line after "content-type:" is the mime type and thus makes it a bit
more resilient to finding absurd mime types in the case where parameters are
added.
Fixes #604711
---
gst/multipart/multipartdemux.c | 20 +++++++++++++++++++-
1 files changed, 19 insertions(+), 1 deletions(-)
diff --git a/gst/multipart/multipartdemux.c b/gst/multipart/multipartdemux.c
index 1fb62e7..1401c6a 100644
--- a/gst/multipart/multipartdemux.c
+++ b/gst/multipart/multipartdemux.c
@@ -351,6 +351,18 @@ get_line_end (const guint8 * data, const guint8 * dataend, guint8 ** end,
return FALSE;
}
+static guint
+get_mime_len (const guint8 * data, guint maxlen)
+{
+ guint8 *x;
+
+ x = (guint8 *) data;
+ while (*x != '\0' && *x != '\r' && *x != '\n' && *x != ';') {
+ x++;
+ }
+ return x - data;
+}
+
static gint
multipart_parse_header (GstMultipartDemux * multipart)
{
@@ -427,8 +439,14 @@ multipart_parse_header (GstMultipartDemux * multipart)
}
if (len >= 14 && !g_ascii_strncasecmp ("content-type:", (gchar *) pos, 13)) {
+ guint mime_len;
+
+ /* only take the mime type up to the first ; if any. After ; there can be
+ * properties that we don't handle yet. */
+ mime_len = get_mime_len (pos + 14, len - 14);
+
g_free (multipart->mime_type);
- multipart->mime_type = g_ascii_strdown ((gchar *) pos + 14, len - 14);
+ multipart->mime_type = g_ascii_strdown ((gchar *) pos + 14, mime_len);
} else if (len >= 15 &&
!g_ascii_strncasecmp ("content-length:", (gchar *) pos, 15)) {
multipart->content_length =
More information about the Gstreamer-commits
mailing list