mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 22:16:16 +01:00
Add a test with a long entity name.
2005-01-24 Matthias Clasen <mclasen@redhat.com> * tests/markups/fail-40.gmarkup: Add a test with a long entity name. * glib/gmarkup.c (unescape_text_state_inside_entity_name): Don't copy the entity name into a short buffer of fixed length. Instead, compare it in place with strncmp(), and do a full strdup() in the error path. (#165100, Simon Budig)
This commit is contained in:
parent
76d763485b
commit
39a681995c
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2005-01-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/markups/fail-40.gmarkup: Add a test with a long entity
|
||||||
|
name.
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text_state_inside_entity_name): Don't
|
||||||
|
copy the entity name into a short buffer of fixed length. Instead,
|
||||||
|
compare it in place with strncmp(), and do a full strdup() in the
|
||||||
|
error path. (#165100, Simon Budig)
|
||||||
|
|
||||||
2005-01-22 Tor Lillqvist <tml@novell.com>
|
2005-01-22 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2005-01-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/markups/fail-40.gmarkup: Add a test with a long entity
|
||||||
|
name.
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text_state_inside_entity_name): Don't
|
||||||
|
copy the entity name into a short buffer of fixed length. Instead,
|
||||||
|
compare it in place with strncmp(), and do a full strdup() in the
|
||||||
|
error path. (#165100, Simon Budig)
|
||||||
|
|
||||||
2005-01-22 Tor Lillqvist <tml@novell.com>
|
2005-01-22 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2005-01-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/markups/fail-40.gmarkup: Add a test with a long entity
|
||||||
|
name.
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text_state_inside_entity_name): Don't
|
||||||
|
copy the entity name into a short buffer of fixed length. Instead,
|
||||||
|
compare it in place with strncmp(), and do a full strdup() in the
|
||||||
|
error path. (#165100, Simon Budig)
|
||||||
|
|
||||||
2005-01-22 Tor Lillqvist <tml@novell.com>
|
2005-01-22 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2005-01-24 Matthias Clasen <mclasen@redhat.com>
|
||||||
|
|
||||||
|
* tests/markups/fail-40.gmarkup: Add a test with a long entity
|
||||||
|
name.
|
||||||
|
|
||||||
|
* glib/gmarkup.c (unescape_text_state_inside_entity_name): Don't
|
||||||
|
copy the entity name into a short buffer of fixed length. Instead,
|
||||||
|
compare it in place with strncmp(), and do a full strdup() in the
|
||||||
|
error path. (#165100, Simon Budig)
|
||||||
|
|
||||||
2005-01-22 Tor Lillqvist <tml@novell.com>
|
2005-01-22 Tor Lillqvist <tml@novell.com>
|
||||||
|
|
||||||
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
* glib/gdate.c (g_date_set_time): Don't g_assert that localtime()
|
||||||
|
@ -458,12 +458,6 @@ unescape_text_state_inside_entity_name (UnescapeContext *ucontext,
|
|||||||
const gchar *p,
|
const gchar *p,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
#define MAX_ENT_LEN 5
|
|
||||||
gchar buf[MAX_ENT_LEN+1] = {
|
|
||||||
'\0', '\0', '\0', '\0', '\0', '\0'
|
|
||||||
};
|
|
||||||
gchar *dest;
|
|
||||||
|
|
||||||
while (p != ucontext->text_end)
|
while (p != ucontext->text_end)
|
||||||
{
|
{
|
||||||
if (*p == ';')
|
if (*p == ';')
|
||||||
@ -488,38 +482,33 @@ unescape_text_state_inside_entity_name (UnescapeContext *ucontext,
|
|||||||
{
|
{
|
||||||
if (p != ucontext->text_end)
|
if (p != ucontext->text_end)
|
||||||
{
|
{
|
||||||
const gchar *src;
|
gint len = p - ucontext->entity_start;
|
||||||
|
|
||||||
src = ucontext->entity_start;
|
|
||||||
dest = buf;
|
|
||||||
while (src != p)
|
|
||||||
{
|
|
||||||
*dest = *src;
|
|
||||||
++dest;
|
|
||||||
++src;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* move to after semicolon */
|
/* move to after semicolon */
|
||||||
p = g_utf8_next_char (p);
|
p = g_utf8_next_char (p);
|
||||||
ucontext->state = USTATE_INSIDE_TEXT;
|
ucontext->state = USTATE_INSIDE_TEXT;
|
||||||
|
|
||||||
if (strcmp (buf, "lt") == 0)
|
if (strncmp (ucontext->entity_start, "lt", len) == 0)
|
||||||
g_string_append_c (ucontext->str, '<');
|
g_string_append_c (ucontext->str, '<');
|
||||||
else if (strcmp (buf, "gt") == 0)
|
else if (strncmp (ucontext->entity_start, "gt", len) == 0)
|
||||||
g_string_append_c (ucontext->str, '>');
|
g_string_append_c (ucontext->str, '>');
|
||||||
else if (strcmp (buf, "amp") == 0)
|
else if (strncmp (ucontext->entity_start, "amp", len) == 0)
|
||||||
g_string_append_c (ucontext->str, '&');
|
g_string_append_c (ucontext->str, '&');
|
||||||
else if (strcmp (buf, "quot") == 0)
|
else if (strncmp (ucontext->entity_start, "quot", len) == 0)
|
||||||
g_string_append_c (ucontext->str, '"');
|
g_string_append_c (ucontext->str, '"');
|
||||||
else if (strcmp (buf, "apos") == 0)
|
else if (strncmp (ucontext->entity_start, "apos", len) == 0)
|
||||||
g_string_append_c (ucontext->str, '\'');
|
g_string_append_c (ucontext->str, '\'');
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
name = g_strndup (ucontext->entity_start, len);
|
||||||
set_unescape_error (ucontext->context, error,
|
set_unescape_error (ucontext->context, error,
|
||||||
p, ucontext->text_end,
|
p, ucontext->text_end,
|
||||||
G_MARKUP_ERROR_PARSE,
|
G_MARKUP_ERROR_PARSE,
|
||||||
_("Entity name '%s' is not known"),
|
_("Entity name '%s' is not known"),
|
||||||
buf);
|
name);
|
||||||
|
g_free (name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
1
tests/markups/fail-40.gmarkup
Normal file
1
tests/markups/fail-40.gmarkup
Normal file
@ -0,0 +1 @@
|
|||||||
|
<bla>&unknownentityname;</bla>
|
Loading…
Reference in New Issue
Block a user