From c6194d2f5b80fa486c09a66da114ed1de92d6ce2 Mon Sep 17 00:00:00 2001 From: Jeremy Lainé Date: Mon, 9 Aug 2010 16:24:19 +0000 Subject: XML RPC spec we should encode booleans as "1" or "0", not "true" or "false" --- example/tests/tests.cpp | 5 ++--- source/xmlrpc.cpp | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/example/tests/tests.cpp b/example/tests/tests.cpp index de48ef62..8e175844 100644 --- a/example/tests/tests.cpp +++ b/example/tests/tests.cpp @@ -352,11 +352,10 @@ void TestXmlRpc::testBase64() void TestXmlRpc::testBool() { - // FIXME : XML-RPC spec says we should write "0" or "1" checkVariant(false, - QByteArray("false")); + QByteArray("0")); checkVariant(true, - QByteArray("true")); + QByteArray("1")); } void TestXmlRpc::testDateTime() diff --git a/source/xmlrpc.cpp b/source/xmlrpc.cpp index 59e61a79..20ca2718 100644 --- a/source/xmlrpc.cpp +++ b/source/xmlrpc.cpp @@ -21,7 +21,7 @@ void XMLRPC::marshall( QXmlStreamWriter *writer, const QVariant &value) writer->writeTextElement("double", value.toString()); break; case QVariant::Bool: - writer->writeTextElement("boolean", (value.toBool()?"true":"false") ); + writer->writeTextElement("boolean", value.toBool() ? "1" : "0"); break; case QVariant::Date: writer->writeTextElement("dateTime.iso8601", value.toDate().toString( Qt::ISODate ) ); @@ -120,7 +120,7 @@ QVariant XMLRPC::demarshall(const QDomElement &elem, QStringList &errors) errors << "I was looking for an double but data was corrupt"; } else if( typeName == "boolean" ) - return QVariant( ( typeData.text().toLower() == "true" || typeData.text() == "1")?true:false ); + return QVariant( typeData.text() == "1" || typeData.text().toLower() == "true" ); else if( typeName == "datetime" || typeName == "datetime.iso8601" ) return QVariant( QDateTime::fromString( typeData.text(), Qt::ISODate ) ); else if( typeName == "array" ) -- cgit v1.2.3