diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2011-12-03 11:21:57 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2011-12-03 11:21:57 +0100 |
| commit | 56f0f398a96146cae851c1847f656a4ff66964dc (patch) | |
| tree | 0d9136b400201c7701e0999b5d0d4dad365e48b6 /src/main.c | |
| parent | 98df387ba96f83f364b1ba1be5f9a3ae9f79e931 (diff) | |
Tooltips uses markup even if column uses text. So change column to markup and escape any '&'
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 57 |
1 files changed, 57 insertions, 0 deletions
@@ -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; +} |
