gst/subparse/samiparse.c: Fix up broken entities before passing them to libxml *sigh*. (#343303).
Original commit message from CVS: Patch by: Young-Ho Cha <ganadist at chollian net> * gst/subparse/samiparse.c: (fix_invalid_entities), (parse_sami): Fix up broken entities before passing them to libxml *sigh*. (#343303).
This commit is contained in:
parent
06ec54d076
commit
a5668b5418
@ -1,3 +1,11 @@
|
|||||||
|
2006-06-10 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
Patch by: Young-Ho Cha <ganadist at chollian net>
|
||||||
|
|
||||||
|
* gst/subparse/samiparse.c: (fix_invalid_entities), (parse_sami):
|
||||||
|
Fix up broken entities before passing them to libxml *sigh*.
|
||||||
|
(#343303).
|
||||||
|
|
||||||
2006-06-09 Thomas Vander Stichele <thomas at apestaart dot org>
|
2006-06-09 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* configure.ac:
|
* configure.ac:
|
||||||
|
@ -349,13 +349,54 @@ sami_context_reset (ParserState * state)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
fix_invalid_entities (const gchar * line)
|
||||||
|
{
|
||||||
|
const gchar *cp, *pp; /* current pointer, previous pointer */
|
||||||
|
gssize size;
|
||||||
|
GString *ret = g_string_new (NULL);
|
||||||
|
|
||||||
|
pp = line;
|
||||||
|
cp = strchr (line, '&');
|
||||||
|
while (cp) {
|
||||||
|
size = cp - pp;
|
||||||
|
ret = g_string_append_len (ret, pp, size);
|
||||||
|
cp++;
|
||||||
|
if (g_ascii_strncasecmp (cp, "nbsp;", 5)
|
||||||
|
&& (!g_ascii_strncasecmp (cp, "nbsp", 4))) {
|
||||||
|
/* translate " " to " " */
|
||||||
|
ret = g_string_append_len (ret, " ", 6);
|
||||||
|
cp += 4;
|
||||||
|
} else if (g_ascii_strncasecmp (cp, "quot;", 5)
|
||||||
|
&& g_ascii_strncasecmp (cp, "amp;", 4)
|
||||||
|
&& g_ascii_strncasecmp (cp, "apos;", 5)
|
||||||
|
&& g_ascii_strncasecmp (cp, "lt;", 3)
|
||||||
|
&& g_ascii_strncasecmp (cp, "gt;", 3)
|
||||||
|
&& g_ascii_strncasecmp (cp, "nbsp;", 5)) {
|
||||||
|
/* translate "&" to "&" */
|
||||||
|
ret = g_string_append_len (ret, "&", 5);
|
||||||
|
} else {
|
||||||
|
/* do not translate */
|
||||||
|
ret = g_string_append_c (ret, '&');
|
||||||
|
}
|
||||||
|
|
||||||
|
pp = cp;
|
||||||
|
cp = strchr (pp, '&');
|
||||||
|
}
|
||||||
|
ret = g_string_append (ret, pp);
|
||||||
|
return g_string_free (ret, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
parse_sami (ParserState * state, const gchar * line)
|
parse_sami (ParserState * state, const gchar * line)
|
||||||
{
|
{
|
||||||
|
gchar *fixed_line;
|
||||||
GstSamiContext *context = (GstSamiContext *) state->user_data;
|
GstSamiContext *context = (GstSamiContext *) state->user_data;
|
||||||
|
|
||||||
htmlParseChunk (context->htmlctxt, line, strlen (line), 0);
|
fixed_line = fix_invalid_entities (line);
|
||||||
|
htmlParseChunk (context->htmlctxt, fixed_line, strlen (fixed_line), 0);
|
||||||
|
g_free (fixed_line);
|
||||||
|
|
||||||
if (context->has_result) {
|
if (context->has_result) {
|
||||||
gchar *r;
|
gchar *r;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user