mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 06:32:10 +01:00
Add testcases for g_message() involving non-printable and unsafe
2004-04-22 Matthias Clasen <mclasen@redhat.com> * tests/testglib.c (main): Add testcases for g_message() involving non-printable and unsafe characters. * glib/gmessages.c (escape_string): Don't assume that string->str remains unchanged over g_string_insert() calls. (#139030, Christophe Saout)
This commit is contained in:
parent
d7af9f1a48
commit
05501852ec
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -1,5 +1,12 @@
|
||||
2004-04-22 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* tests/testglib.c (main): Add testcases for g_message() involving
|
||||
non-printable and unsafe characters.
|
||||
|
||||
* glib/gmessages.c (escape_string): Don't assume that
|
||||
string->str remains unchanged over g_string_insert()
|
||||
calls. (#139030, Christophe Saout)
|
||||
|
||||
* glib/gstrfuncs.c (g_ascii_strtod): Fix problems when a
|
||||
locale-specific decimal separator directly follows a
|
||||
number. (#138424, Nickolay V. Shmyrev)
|
||||
|
@ -791,16 +791,19 @@ escape_string (GString *string)
|
||||
if (wc == (gunichar)-1 || wc == (gunichar)-2)
|
||||
{
|
||||
gchar *tmp;
|
||||
|
||||
g_string_erase (string, p - string->str, 1);
|
||||
guint pos;
|
||||
|
||||
pos = p - string->str;
|
||||
|
||||
/* Emit invalid UTF-8 as hex escapes
|
||||
*/
|
||||
tmp = g_strdup_printf ("\\x%02x", (guint)(guchar)*p);
|
||||
g_string_insert (string, p - string->str, tmp);
|
||||
g_string_erase (string, pos, 1);
|
||||
g_string_insert (string, pos, tmp);
|
||||
|
||||
p = string->str + (pos + 4); /* Skip over escape sequence */
|
||||
|
||||
g_free (tmp);
|
||||
|
||||
p += 4; /* Skip over escape sequence */
|
||||
|
||||
continue;
|
||||
}
|
||||
if (wc == '\r')
|
||||
@ -815,16 +818,19 @@ escape_string (GString *string)
|
||||
if (!safe)
|
||||
{
|
||||
gchar *tmp;
|
||||
guint pos;
|
||||
|
||||
pos = p - string->str;
|
||||
|
||||
g_string_erase (string, p - string->str, g_utf8_next_char (p) - p);
|
||||
/* Largest char we escape is 0x0a, so we don't have to worry
|
||||
* about 8-digit \Uxxxxyyyy
|
||||
*/
|
||||
tmp = g_strdup_printf ("\\u%04x", wc);
|
||||
g_string_insert (string, p - string->str, tmp);
|
||||
g_string_erase (string, pos, g_utf8_next_char (p) - p);
|
||||
g_string_insert (string, pos, tmp);
|
||||
g_free (tmp);
|
||||
|
||||
p += 6; /* Skip over escape sequence */
|
||||
p = string->str + (pos + 6); /* Skip over escape sequence */
|
||||
}
|
||||
else
|
||||
p = g_utf8_next_char (p);
|
||||
|
@ -1230,6 +1230,8 @@ main (int argc,
|
||||
g_message ("the next warning is a test:");
|
||||
string = NULL;
|
||||
g_print (string);
|
||||
g_message ("non-printable UTF-8: \"\xc3\xa4\xda\x85\"");
|
||||
g_message ("unsafe chars: \"\x10\x11\x12\n\t\x7f\x81\x82\x83\"");
|
||||
|
||||
g_print ("checking endian macros (host is ");
|
||||
#if G_BYTE_ORDER == G_BIG_ENDIAN
|
||||
|
Loading…
x
Reference in New Issue
Block a user