tracker r1671 - in branches/indexer-split: . src/libtracker-common src/libtracker-db
- From: mr svn gnome org
- To: svn-commits-list gnome org
- Subject: tracker r1671 - in branches/indexer-split: . src/libtracker-common src/libtracker-db
- Date: Fri, 13 Jun 2008 09:17:39 +0000 (UTC)
Author: mr
Date: Fri Jun 13 09:17:39 2008
New Revision: 1671
URL: http://svn.gnome.org/viewvc/tracker?rev=1671&view=rev
Log:
* src/libtracker-common/tracker-dbus.c:
(tracker_dbus_slist_to_strv), (tracker_dbus_async_queue_to_strv):
* src/libtracker-db/tracker-db-dbus.c:
(tracker_dbus_query_result_to_strv),
(tracker_dbus_query_result_to_hash_table),
(tracker_dbus_query_result_to_ptr_array): Now we UTF-8 check ALL
strings in these functions since they are sent over DBus and we
don't want DBus calling _exit() for us if the string is invalid
UTF-8.
Modified:
branches/indexer-split/ChangeLog
branches/indexer-split/src/libtracker-common/tracker-dbus.c
branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
Modified: branches/indexer-split/src/libtracker-common/tracker-dbus.c
==============================================================================
--- branches/indexer-split/src/libtracker-common/tracker-dbus.c (original)
+++ branches/indexer-split/src/libtracker-common/tracker-dbus.c Fri Jun 13 09:17:39 2008
@@ -71,6 +71,12 @@
strv = g_new0 (gchar*, g_slist_length (list) + 1);
for (l = list; l != NULL; l = l->next) {
+ if (!g_utf8_validate (l->data, -1, NULL)) {
+ g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8",
+ (gchar*) l->data);
+ continue;
+ }
+
strv[i++] = g_strdup (l->data);
}
@@ -104,7 +110,14 @@
/* Get next item and wait 0.1 seconds max per try */
str = g_async_queue_timed_pop (queue, &t);
+
if (str) {
+ if (!g_utf8_validate (str, -1, NULL)) {
+ g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
+ g_free (str);
+ continue;
+ }
+
strv[i++] = str;
} else {
/* We don't expect this */
Modified: branches/indexer-split/src/libtracker-db/tracker-db-dbus.c
==============================================================================
--- branches/indexer-split/src/libtracker-db/tracker-db-dbus.c (original)
+++ branches/indexer-split/src/libtracker-db/tracker-db-dbus.c Fri Jun 13 09:17:39 2008
@@ -32,17 +32,27 @@
gint rows = 0;
if (result_set) {
- gboolean valid = TRUE;
- gint i = 0;
+ gchar *str;
+ gboolean valid = TRUE;
+ gint i = 0;
rows = tracker_db_result_set_get_n_rows (result_set);
strv = g_new (gchar*, rows + 1);
while (valid) {
- tracker_db_result_set_get (result_set, column, &strv[i], -1);
+
+ tracker_db_result_set_get (result_set, column, &str, -1);
+
+ if (!g_utf8_validate (str, -1, NULL)) {
+ g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
+ g_free (str);
+ str = g_strdup ("");
+ }
+
+ strv[i++] = str;
valid = tracker_db_result_set_iter_next (result_set);
- i++;
}
+
strv[i] = NULL;
}
@@ -85,13 +95,19 @@
values = tracker_dbus_g_value_slice_new (G_TYPE_STRV);
for (i = 1; i < field_count; i++) {
- GValue value;
- const gchar *str;
+ GValue value;
+ gchar *str;
_tracker_db_result_set_get_value (result_set, i, &value);
if (g_value_transform (&value, &transform)) {
str = g_value_dup_string (&transform);
+
+ if (!g_utf8_validate (str, -1, NULL)) {
+ g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
+ g_free (str);
+ str = g_strdup ("");
+ }
} else {
str = g_strdup ("");
}
@@ -135,13 +151,19 @@
/* Append fields to the array */
for (i = 0; i < columns; i++) {
- GValue value = { 0, };
- const gchar *str;
+ GValue value = { 0, };
+ gchar *str;
_tracker_db_result_set_get_value (result_set, i, &value);
if (g_value_transform (&value, &transform)) {
str = g_value_dup_string (&transform);
+
+ if (!g_utf8_validate (str, -1, NULL)) {
+ g_warning ("Could not add string:'%s' to GStrv, invalid UTF-8", str);
+ g_free (str);
+ str = g_strdup ("");
+ }
} else {
str = g_strdup ("");
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]