From 26f33a1c12668a0ff2e82e2eac2d4ff82b518b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20Nie=C3=9Fen?= Date: Sun, 21 Jun 2015 21:43:20 +0200 Subject: [PATCH] add fake workaround for the nasty bahvior of QJSON --- src/http/Server.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/http/Server.cpp b/src/http/Server.cpp index 576d55bf5..b1332ae6e 100644 --- a/src/http/Server.cpp +++ b/src/http/Server.cpp @@ -216,6 +216,24 @@ void Server::handleRequest(const QByteArray in, QByteArray *out) } *out = protocolResp.toJson().toUtf8(); + + // THIS IS A FAKE HACK!!! + // the real "error" is a misbehavior in the QJSON qobject2qvariant method + // 1. getLogins returns an empty QList into protocolResp->m_entries + // in toJson() function the following happend: + // 2. QJson::QObjectHelper::qobject2qvariant marks m_entries as invalid !!! + // 3. QJson::Serializer write out Entries as null instead of empty list + //(4. ChromeIPass tries to access Entries.length and fails with null pointer exception) + // the fake workaround replaces the (wrong) "Entries":null with "Entries:[] to give + // chromeIPass (and passIFox) en empty list + QString tmp_out = QString(*out); + int tmp_pos1 = tmp_out.indexOf("\"Count\":0,"); + int tmp_pos2 = tmp_out.indexOf("\"Entries\":null,"); + if (tmp_pos1 != -1 && tmp_pos2 != -1) { + tmp_out.replace(tmp_pos2, 15, "\"Entries\":[],"); + } + *out = tmp_out.toUtf8(); + Q_EMIT donewrk(); }