summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Taylor <otaylor@redhat.com>2002-07-31 16:46:55 +0000
committerOwen Taylor <otaylor@src.gnome.org>2002-07-31 16:46:55 +0000
commit682109791d6b704d169aca87c1c0f4dc0dace9df (patch)
tree123c48edd4eb6fbd0b434e380d3618df244c0715
parentd4d6d7317dce6981a8491fb52f9211694830bf2b (diff)
downloadpango-682109791d6b704d169aca87c1c0f4dc0dace9df.tar.gz
Avoid using g_strescape(), since it mangles UTF-8. (#89479, Yao Zhang)
Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com> * pango/querymodules.c (string_needs_escape): Avoid using g_strescape(), since it mangles UTF-8. (#89479, Yao Zhang)
-rw-r--r--ChangeLog6
-rw-r--r--ChangeLog.pre-1-106
-rw-r--r--ChangeLog.pre-1-26
-rw-r--r--ChangeLog.pre-1-46
-rw-r--r--ChangeLog.pre-1-66
-rw-r--r--ChangeLog.pre-1-86
-rw-r--r--pango/querymodules.c46
7 files changed, 80 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/ChangeLog.pre-1-10 b/ChangeLog.pre-1-10
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog.pre-1-10
+++ b/ChangeLog.pre-1-10
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/ChangeLog.pre-1-2 b/ChangeLog.pre-1-2
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog.pre-1-2
+++ b/ChangeLog.pre-1-2
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/ChangeLog.pre-1-4 b/ChangeLog.pre-1-4
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog.pre-1-4
+++ b/ChangeLog.pre-1-4
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/ChangeLog.pre-1-6 b/ChangeLog.pre-1-6
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog.pre-1-6
+++ b/ChangeLog.pre-1-6
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/ChangeLog.pre-1-8 b/ChangeLog.pre-1-8
index 13d4e345..b92ffa7c 100644
--- a/ChangeLog.pre-1-8
+++ b/ChangeLog.pre-1-8
@@ -1,3 +1,9 @@
+Wed Jul 31 12:38:36 2002 Owen Taylor <otaylor@redhat.com>
+
+ * pango/querymodules.c (string_needs_escape): Avoid
+ using g_strescape(), since it mangles UTF-8.
+ (#89479, Yao Zhang)
+
Tue Jul 30 23:10:14 2002 Owen Taylor <otaylor@redhat.com>
* pango/shape.c (pango_shape): Set is_cluster_start
diff --git a/pango/querymodules.c b/pango/querymodules.c
index 5ae7789a..95c67d89 100644
--- a/pango/querymodules.c
+++ b/pango/querymodules.c
@@ -42,6 +42,48 @@
#endif
#define SOEXT_LEN (strlen (SOEXT))
+static gboolean
+string_needs_escape (const char *str)
+{
+ while (TRUE)
+ {
+ char c = *str++;
+
+ if (!c)
+ return FALSE;
+ else if (c == '\"' || g_ascii_isspace (c))
+ return TRUE;
+ }
+}
+
+static char *
+escape_string (const char *str)
+{
+ GString *result = g_string_new ("");
+
+ while (TRUE)
+ {
+ char c = *str++;
+
+ switch (c)
+ {
+ case '\0':
+ goto done;
+ case '\n':
+ g_string_append (result, "\\n");
+ break;
+ case '\"':
+ g_string_append (result, "\\\"");
+ break;
+ default:
+ g_string_append_c (result, c);
+ }
+ }
+
+ done:
+ return g_string_free (result, FALSE);
+}
+
void
query_module (const char *dir, const char *name)
{
@@ -78,10 +120,10 @@ query_module (const char *dir, const char *name)
const gchar *quote;
gchar *quoted_path;
- if (strchr (path, ' ') != NULL)
+ if (string_needs_escape (path))
{
quote = "\"";
- quoted_path = g_strescape (path, NULL);
+ quoted_path = escape_string (path);
}
else
{