summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qlocalsocket_unix.cpp
diff options
context:
space:
mode:
authorDāvis Mosāns <davispuh@gmail.com>2015-08-27 00:50:11 +0300
committerDāvis Mosāns <davispuh@gmail.com>2015-09-27 19:38:29 +0000
commite18554d4f7722b7fc5b576efb7ca429112789a05 (patch)
treed6a2a25572bfc74ff37f3ec0aa65491d0661fe96 /src/network/socket/qlocalsocket_unix.cpp
parentbb281eea179d50a413f4ec1ff172d27ee48d3a41 (diff)
Network: Use QFile::encodeName for POSIX paths instead of toLatin1
POSIX API doesn't really have defined encoding and kernel works with null-terminated byte strings (char *) without any knowledge about encodings. But usually applications use LANG (and LC_*) as encoding making it possible to use any encoding user wishes, including full Unicode support when UTF-8 is used. This allows to create and listen to sockets with paths containing non-latin characters. eg. listen(QString("/run/υποδοχή")); Change-Id: I022ac6a8a4575103125c48768a66bef88a232a2a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Dāvis Mosāns <davispuh@gmail.com>
Diffstat (limited to 'src/network/socket/qlocalsocket_unix.cpp')
-rw-r--r--src/network/socket/qlocalsocket_unix.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/network/socket/qlocalsocket_unix.cpp b/src/network/socket/qlocalsocket_unix.cpp
index 77c5028fb3..bb0f11f038 100644
--- a/src/network/socket/qlocalsocket_unix.cpp
+++ b/src/network/socket/qlocalsocket_unix.cpp
@@ -268,15 +268,16 @@ void QLocalSocketPrivate::_q_connectToSocket()
connectingPathName += QLatin1Char('/') + connectingName;
}
+ const QByteArray encodedConnectingPathName = QFile::encodeName(connectingPathName);
struct sockaddr_un name;
name.sun_family = PF_UNIX;
- if (sizeof(name.sun_path) < (uint)connectingPathName.toLatin1().size() + 1) {
+ if (sizeof(name.sun_path) < (uint)encodedConnectingPathName.size() + 1) {
QString function = QLatin1String("QLocalSocket::connectToServer");
errorOccurred(QLocalSocket::ServerNotFoundError, function);
return;
}
- ::memcpy(name.sun_path, connectingPathName.toLatin1().data(),
- connectingPathName.toLatin1().size() + 1);
+ ::memcpy(name.sun_path, encodedConnectingPathName.constData(),
+ encodedConnectingPathName.size() + 1);
if (-1 == qt_safe_connect(connectingSocket, (struct sockaddr *)&name, sizeof(name))) {
QString function = QLatin1String("QLocalSocket::connectToServer");
switch (errno)