[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[vidalia-svn] r4352: Tor doesn't consistently escape non-ASCII characters contain (vidalia/trunk/src/torcontrol)



Author: edmanm
Date: 2010-07-14 11:47:55 -0400 (Wed, 14 Jul 2010)
New Revision: 4352

Modified:
   vidalia/trunk/src/torcontrol/ControlSocket.cpp
Log:

Tor doesn't consistently escape non-ASCII characters contained in certain
command responses (e.g., 'getinfo config-file'), so don't assume
ASCII-only in the repsonse. Instead, use the local 8-bit encoding for
sending and receiving commands and responses (which is usually a superset
of ASCII).


Modified: vidalia/trunk/src/torcontrol/ControlSocket.cpp
===================================================================
--- vidalia/trunk/src/torcontrol/ControlSocket.cpp	2010-07-14 15:45:22 UTC (rev 4351)
+++ vidalia/trunk/src/torcontrol/ControlSocket.cpp	2010-07-14 15:47:55 UTC (rev 4352)
@@ -75,7 +75,7 @@
   tc::debug("Control Command: %1").arg(strCmd.trimmed());
 
   /* Attempt to send the command to Tor */
-  if (write(strCmd.toAscii()) != strCmd.length()) {
+  if (write(strCmd.toLocal8Bit()) != strCmd.length()) {
     return err(errmsg, tr("Error sending control command. [%1]")
                                             .arg(errorString()));
   }
@@ -91,7 +91,7 @@
   char buffer[1024];  /* Read in 1024 byte chunks at a time */
   int bytesRecv = QAbstractSocket::readLine(buffer, 1024);
   while (bytesRecv != -1) {
-    line.append(buffer);
+    line.append(QString::fromLocal8Bit(buffer, bytesRecv));
     if (buffer[bytesRecv-1] == '\n') {
       break;
     }