On 15:57 Sun 08 Feb , Dmitry E. Oboukhov wrote: Tsbdo> Package: rtorrent Tsbdo> Version: 0.7.9 Tsbdo> Version: 0.8.4 Tsbdo> Tags: patch Tsbdo> Severity: important Tsbdo> Forwarded: http://libtorrent.rakshasa.no/ticket/1633
Tsbdo> When downloading the torrent from attach into rtorrent then on request Tsbdo> of the d.get_message command on SCGI there is responded a non-correct Tsbdo> XML (probably there are problems with coding). It leads to the fact Tsbdo> that the great majority of the XML parsers known to me doesn't work. Tsbdo> There are also problems with the message display in the main rtorrent Tsbdo> interface GUI. Tsbdo> This bug was met in version 0.8.4 and in version 0.7.9 as well. -- ... mpd is off . ''`. Dmitry E. Oboukhov : :’ : email: [email protected] jabber://[email protected] `. `~’ GPGKey: 1024D / F8E26537 2006-11-21 `- 1B23 D4F8 8EC0 D902 0555 E438 AB8C 00CF F8E2 6537
# Fix crashes/errors due to rtorrent attempting to pass non-utf-8 strings to xmlrpc.
Index: rtorrent/src/rpc/xmlrpc.cc
===================================================================
--- rtorrent-0.7.9/src/rpc/xmlrpc.cc (revision 1078)
+++ rtorrent-0.7.9/src/rpc/xmlrpc.cc (working copy)
@@ -371,8 +371,34 @@
#endif
case torrent::Object::TYPE_STRING:
- return xmlrpc_string_new(env, object.as_string().c_str());
+ {
+#ifdef XMLRPC_HAVE_I8
+ // The versions that support I8 do implicit utf-8 validation.
+ xmlrpc_value* result = xmlrpc_string_new(env, object.as_string().c_str());
+#else
+ // In older versions, xmlrpc-c doesn't validate the utf-8 encoding itself.
+ xmlrpc_validate_utf8(env, object.as_string().c_str(), object.as_string().length());
+ xmlrpc_value* result = env->fault_occurred ? NULL : xmlrpc_string_new(env, object.as_string().c_str());
+#endif
+
+ if (env->fault_occurred) {
+ xmlrpc_env_clean(env);
+ xmlrpc_env_init(env);
+
+ const std::string& str = object.as_string();
+ char buffer[str.size() + 1];
+ char* dst = buffer;
+ for (std::string::const_iterator itr = str.begin(); itr != str.end(); ++itr)
+ *dst++ = ((*itr < 0x20 && *itr != '\r' && *itr != '\n' && *itr != '\t') || (*itr & 0x80)) ? '?' : *itr;
+ *dst = 0;
+
+ result = xmlrpc_string_new(env, buffer);
+ }
+
+ return result;
+ }
+
case torrent::Object::TYPE_LIST:
{
xmlrpc_value* result = xmlrpc_array_new(env);
signature.asc
Description: Digital signature

