summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2004-04-22 20:17:54 +0000
committerMatthias Clasen <matthiasc@src.gnome.org>2004-04-22 20:17:54 +0000
commit05501852ecb0bd3d048273c0ac063fe739983d8d (patch)
tree90dda77fd863a59c7f03171c46cb3db644f989b9
parentd7af9f1a488b6cdf0ba8c22c6d502283b7a52913 (diff)
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)
-rw-r--r--ChangeLog7
-rw-r--r--ChangeLog.pre-2-107
-rw-r--r--ChangeLog.pre-2-127
-rw-r--r--ChangeLog.pre-2-47
-rw-r--r--ChangeLog.pre-2-67
-rw-r--r--ChangeLog.pre-2-87
-rw-r--r--glib/gmessages.c22
-rw-r--r--tests/testglib.c2
8 files changed, 58 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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)
diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog.pre-2-10
+++ b/ChangeLog.pre-2-10
@@ -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)
diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog.pre-2-12
+++ b/ChangeLog.pre-2-12
@@ -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)
diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog.pre-2-4
+++ b/ChangeLog.pre-2-4
@@ -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)
diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog.pre-2-6
+++ b/ChangeLog.pre-2-6
@@ -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)
diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8
index b6c1976a2..fe7d16027 100644
--- a/ChangeLog.pre-2-8
+++ b/ChangeLog.pre-2-8
@@ -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)
diff --git a/glib/gmessages.c b/glib/gmessages.c
index 4be1d548e..fffd40275 100644
--- a/glib/gmessages.c
+++ b/glib/gmessages.c
@@ -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_free (tmp);
+ g_string_erase (string, pos, 1);
+ g_string_insert (string, pos, tmp);
- p += 4; /* Skip over escape sequence */
+ p = string->str + (pos + 4); /* Skip over escape sequence */
+ g_free (tmp);
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);
diff --git a/tests/testglib.c b/tests/testglib.c
index d0bd7bb14..4c9cc4125 100644
--- a/tests/testglib.c
+++ b/tests/testglib.c
@@ -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