mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-29 18:48:44 +00:00
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.
This commit is contained in:
parent
91bbfbd819
commit
debe9caa36
1 changed files with 5 additions and 3 deletions
|
@ -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 ***/
|
||||
|
|
Loading…
Reference in a new issue