summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@yahoo.com>2011-12-03 11:21:57 +0100
committerJoel Klinghed <the_jk@yahoo.com>2011-12-03 11:21:57 +0100
commit56f0f398a96146cae851c1847f656a4ff66964dc (patch)
tree0d9136b400201c7701e0999b5d0d4dad365e48b6 /src
parent98df387ba96f83f364b1ba1be5f9a3ae9f79e931 (diff)
Tooltips uses markup even if column uses text. So change column to markup and escape any '&'
Diffstat (limited to 'src')
-rw-r--r--src/main.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 9c79b31..2dd2a9b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1977,6 +1977,8 @@ gint liststore_default_compare_func(GtkTreeModel* model,
}
}
+static gchar* safe_str(gchar* str);
+
gboolean hashlist_item_sync(worker_data_t* data, xmlrpc_env * const env,
const xmlrpc_value * const line,
torrent_data_t* torrent_data)
@@ -2046,6 +2048,7 @@ gboolean hashlist_item_sync(worker_data_t* data, xmlrpc_env * const env,
}
g_free(torrent_data->title);
torrent_data->title = (gchar*)tmpstr;
+ torrent_data->title = safe_str(torrent_data->title);
/* d.size_bytes */
xmlrpc_array_read_item(env, line, 5, &item);
@@ -2357,3 +2360,57 @@ gboolean do_buttonpressed(GtkWidget *treeview, GdkEventButton *event,
return FALSE;
}
+
+gchar* safe_str(gchar* str)
+{
+ gchar* pos;
+ gchar* ret = NULL;
+ gsize size = 0, alloc = 0;
+ pos = strchr(str, '&');
+ if (pos == NULL)
+ {
+ return str;
+ }
+ size = strlen(str);
+ alloc = size + 10;
+ ret = g_malloc(alloc);
+ if (ret == NULL)
+ {
+ return str;
+ }
+ memcpy(ret, str, size + 1);
+ pos = ret + (pos - str);
+ g_free(str);
+ for (;;)
+ {
+ gchar* last;
+ if (size + 5 >= alloc)
+ {
+ size_t p = pos - ret;
+ size_t na = alloc * 2;
+ gchar* tmp;
+ if (na < size + 10)
+ {
+ na = size + 10;
+ }
+ tmp = g_realloc(ret, na);
+ if (tmp == NULL)
+ {
+ break;
+ }
+ ret = tmp;
+ alloc = na;
+ pos = ret + p;
+ }
+ last = pos + 5;
+ memmove(last, pos + 1, size - (pos - ret));
+ memcpy(pos + 1, "amp;", 4);
+ size += 4;
+ pos = strchr(last, '&');
+ if (pos == NULL)
+ {
+ break;
+ }
+ }
+ return ret;
+}