gst/typefind/gsttypefindfunctions.c: Better detection for multipart/x-mixed-replace...
authorSjoerd Simons <sjoerd@luon.net>
Tue, 8 Aug 2006 08:41:13 +0000 (08:41 +0000)
committerTim-Philipp Müller <tim@centricular.net>
Tue, 8 Aug 2006 08:41:13 +0000 (08:41 +0000)
Original commit message from CVS:
Patch by: Sjoerd Simons  <sjoerd at luon net>
* gst/typefind/gsttypefindfunctions.c: (multipart_type_find):
Better detection for multipart/x-mixed-replace: accept leading
whitespaces before the boundary marker as well (as our very own
multipartmux used to produce) (#349068).

ChangeLog
gst/typefind/gsttypefindfunctions.c

index 4ed6cdf..1cadba0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2006-08-08  Tim-Philipp Müller  <tim at centricular dot net>
+
+       Patch by: Sjoerd Simons  <sjoerd at luon net>
+
+       * gst/typefind/gsttypefindfunctions.c: (multipart_type_find):
+         Better detection for multipart/x-mixed-replace: accept leading
+         whitespaces before the boundary marker as well (as our very own
+         multipartmux used to produce) (#349068).
+
 2006-08-07  Tim-Philipp Müller  <tim at centricular dot net>
 
        Patch by: Young-Ho Cha  <ganadist at chollian net>
index fa68f85..157df08 100644 (file)
@@ -934,7 +934,7 @@ GST_STATIC_CAPS ("multipart/x-mixed-replace");
 #define MULTIPART_CAPS gst_static_caps_get(&multipart_caps)
 
 /* multipart/x-mixed replace is: 
- *   --<some ascii chars>[\r]\n
+ *   <maybe some whitespace>--<some ascii chars>[\r]\n
  *   <more ascii chars>[\r]\nContent-type:<more ascii>[\r]\n */
 static void
 multipart_type_find (GstTypeFind * tf, gpointer unused)
@@ -942,8 +942,15 @@ multipart_type_find (GstTypeFind * tf, gpointer unused)
   guint8 *data;
   guint8 *x;
 
-  data = gst_type_find_peek (tf, 0, 2);
-  if (!data || data[0] != '-' || data[1] != '-')
+#define MULTIPART_MAX_BOUNDARY_OFFSET 16
+  data = gst_type_find_peek (tf, 0, MULTIPART_MAX_BOUNDARY_OFFSET);
+  if (!data)
+    return;
+
+  for (x = data;
+      x - data < MULTIPART_MAX_BOUNDARY_OFFSET - 2 && g_ascii_isspace (*x);
+      x++);
+  if (x[0] != '-' || x[1] != '-')
     return;
 
   /* Could be okay, peek what should be enough for a complete header */