From debe9caa36bfa63664fd7b09f207dffc402445a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 9 Dec 2011 01:31:20 +0000 Subject: [PATCH] typefindfunctions: only typefind text with a BOM as text/utf16 or text/utf32 We added the utf typefinder because the mp3 typefinder was a tad overzealous when it came to typefinding things as mp3, and replaced it with even more overzealous utf16/32 typefinders. Fixes unit test. --- gst/typefind/gsttypefindfunctions.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gst/typefind/gsttypefindfunctions.c b/gst/typefind/gsttypefindfunctions.c index d7541f47cc..27823b64bf 100644 --- a/gst/typefind/gsttypefindfunctions.c +++ b/gst/typefind/gsttypefindfunctions.c @@ -281,7 +281,7 @@ check_utf32 (const guint8 * data, gint len, gint endianness) static void unicode_type_find (GstTypeFind * tf, const GstUnicodeTester * tester, - guint n_tester, const char *media_type) + guint n_tester, const char *media_type, gboolean require_bom) { size_t n; gint len = 4; @@ -313,6 +313,8 @@ unicode_type_find (GstTypeFind * tf, const GstUnicodeTester * tester, if (!memcmp (data, tester[n].bom, tester[n].bomlen)) bom_boost = tester[n].boost; } + if (require_bom && bom_boost == 0) + continue; if (!(*tester[n].checker) (data, len, tester[n].endianness)) continue; tmpprob = GST_TYPE_FIND_POSSIBLE - 20 + bom_boost; @@ -342,7 +344,7 @@ utf16_type_find (GstTypeFind * tf, gpointer unused) {2, "\xfe\xff", check_utf16, 20, G_BIG_ENDIAN}, }; unicode_type_find (tf, utf16tester, G_N_ELEMENTS (utf16tester), - "text/utf-16"); + "text/utf-16", TRUE); } static GstStaticCaps utf32_caps = GST_STATIC_CAPS ("text/utf-32"); @@ -357,7 +359,7 @@ utf32_type_find (GstTypeFind * tf, gpointer unused) {4, "\x00\x00\xfe\xff", check_utf32, 20, G_BIG_ENDIAN} }; unicode_type_find (tf, utf32tester, G_N_ELEMENTS (utf32tester), - "text/utf-32"); + "text/utf-32", TRUE); } /*** text/uri-list ***/ -- 2.34.1