summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gui/viewtorrents.glade38
-rw-r--r--src/main.c57
2 files changed, 76 insertions, 19 deletions
diff --git a/gui/viewtorrents.glade b/gui/viewtorrents.glade
index 7aee1f2..5f95115 100644
--- a/gui/viewtorrents.glade
+++ b/gui/viewtorrents.glade
@@ -5,18 +5,20 @@
<object class="GtkAccelGroup" id="accelgroup1"/>
<object class="GtkActionGroup" id="actiongroup">
<child>
- <object class="GtkAction" id="connectaction">
- <property name="label" translatable="yes">Connect</property>
- <property name="tooltip" translatable="yes">Connect to rTorrent</property>
- <property name="stock_id">gtk-connect</property>
+ <object class="GtkAction" id="rehashaction">
+ <property name="label" translatable="yes">Rehash</property>
+ <property name="tooltip" translatable="yes">Rehash selected torrent</property>
+ <property name="stock_id">gtk-refresh</property>
</object>
+ <accelerator key="r" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
- <object class="GtkAction" id="disconnectaction">
- <property name="label" translatable="yes">Disconnect</property>
- <property name="tooltip" translatable="yes">Disconnect from rTorrent</property>
- <property name="stock_id">gtk-disconnect</property>
+ <object class="GtkAction" id="stopaction">
+ <property name="label" translatable="yes">Stop</property>
+ <property name="tooltip" translatable="yes">Stop selected torrent</property>
+ <property name="stock_id">gtk-media-stop</property>
</object>
+ <accelerator key="d" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
<object class="GtkAction" id="startaction">
@@ -27,20 +29,18 @@
<accelerator key="s" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
- <object class="GtkAction" id="stopaction">
- <property name="label" translatable="yes">Stop</property>
- <property name="tooltip" translatable="yes">Stop selected torrent</property>
- <property name="stock_id">gtk-media-stop</property>
+ <object class="GtkAction" id="disconnectaction">
+ <property name="label" translatable="yes">Disconnect</property>
+ <property name="tooltip" translatable="yes">Disconnect from rTorrent</property>
+ <property name="stock_id">gtk-disconnect</property>
</object>
- <accelerator key="d" modifiers="GDK_CONTROL_MASK"/>
</child>
<child>
- <object class="GtkAction" id="rehashaction">
- <property name="label" translatable="yes">Rehash</property>
- <property name="tooltip" translatable="yes">Rehash selected torrent</property>
- <property name="stock_id">gtk-refresh</property>
+ <object class="GtkAction" id="connectaction">
+ <property name="label" translatable="yes">Connect</property>
+ <property name="tooltip" translatable="yes">Connect to rTorrent</property>
+ <property name="stock_id">gtk-connect</property>
</object>
- <accelerator key="r" modifiers="GDK_CONTROL_MASK"/>
</child>
</object>
<object class="GtkAboutDialog" id="aboutdialog">
@@ -568,7 +568,7 @@ If authentication is needed, enter username and password as well.</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertitle"/>
<attributes>
- <attribute name="text">1</attribute>
+ <attribute name="markup">1</attribute>
</attributes>
</child>
</object>
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;
+}