mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 01:00:37 +00:00
ssaparse: ignore invalid UTF-8 in init section
The codec data blob we get from matroskademux with the SSA/ASS init section is supposed to be valid UTF-8. If it's not, just continue with the bits that are valid UTF-8 instead of erroring out. We don't actually parse the init section yet anyway.. https://bugzilla.gnome.org/show_bug.cgi?id=607630
This commit is contained in:
parent
6549db36cd
commit
53072a4326
1 changed files with 13 additions and 11 deletions
|
@ -150,10 +150,11 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
|
||||||
const GValue *val;
|
const GValue *val;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
|
const guchar bom_utf8[] = { 0xEF, 0xBB, 0xBF };
|
||||||
|
const gchar *end;
|
||||||
GstBuffer *priv;
|
GstBuffer *priv;
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
gchar *ptr;
|
gchar *ptr;
|
||||||
gsize left;
|
gsize left, bad_offset;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
|
|
||||||
s = gst_caps_get_structure (caps, 0);
|
s = gst_caps_get_structure (caps, 0);
|
||||||
|
@ -172,7 +173,10 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
|
||||||
|
|
||||||
gst_buffer_ref (priv);
|
gst_buffer_ref (priv);
|
||||||
|
|
||||||
gst_buffer_map (priv, &map, GST_MAP_READ);
|
if (!gst_buffer_map (priv, &map, GST_MAP_READ))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
GST_MEMDUMP_OBJECT (parse, "init section", map.data, map.size);
|
||||||
|
|
||||||
ptr = (gchar *) map.data;
|
ptr = (gchar *) map.data;
|
||||||
left = map.size;
|
left = map.size;
|
||||||
|
@ -186,8 +190,13 @@ gst_ssa_parse_setcaps (GstPad * sinkpad, GstCaps * caps)
|
||||||
if (!strstr (ptr, "[Script Info]"))
|
if (!strstr (ptr, "[Script Info]"))
|
||||||
goto invalid_init;
|
goto invalid_init;
|
||||||
|
|
||||||
if (!g_utf8_validate (ptr, left, NULL))
|
if (!g_utf8_validate (ptr, left, &end)) {
|
||||||
goto invalid_utf8;
|
bad_offset = (gsize) (end - ptr);
|
||||||
|
GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8. Problem at "
|
||||||
|
"byte offset %" G_GSIZE_FORMAT, bad_offset);
|
||||||
|
/* continue with valid UTF-8 data */
|
||||||
|
left = bad_offset;
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: parse initial section */
|
/* FIXME: parse initial section */
|
||||||
parse->ini = g_strndup (ptr, left);
|
parse->ini = g_strndup (ptr, left);
|
||||||
|
@ -212,13 +221,6 @@ invalid_init:
|
||||||
gst_buffer_unref (priv);
|
gst_buffer_unref (priv);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
invalid_utf8:
|
|
||||||
{
|
|
||||||
GST_WARNING_OBJECT (parse, "Init section is not valid UTF-8");
|
|
||||||
gst_buffer_unmap (priv, &map);
|
|
||||||
gst_buffer_unref (priv);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
|
Loading…
Reference in a new issue