Skip to content

Commit

Permalink
XML plist serializer: Do not output invalid date/null bytearrays.
Browse files Browse the repository at this point in the history
The plist parser in Cocoa is really picky and specifies that values
in a dictionary may not be null.  An empty string is okay as it's not
null, it's just an empty string-- but Date cannot be empty.

Do not serialize invalid dates or empty binary data.
  • Loading branch information
Robert McNamara committed Mar 14, 2012
1 parent e42b2db commit 4fee6b1
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions mythtv/libs/libmythupnp/serializers/xmlplistSerializer.cpp
Expand Up @@ -89,19 +89,25 @@ void XmlPListSerializer::RenderValue(const QString &sName,

case QVariant::DateTime:
{
if (needKey)
m_pXmlWriter->writeTextElement("key", sName);
m_pXmlWriter->writeTextElement("date", vValue.toDateTime()
.toUTC().toString("yyyy-MM-ddThh:mm:ssZ"));
if (vValue.toDateTime().isValid())
{
if (needKey)
m_pXmlWriter->writeTextElement("key", sName);
m_pXmlWriter->writeTextElement("date", vValue.toDateTime()
.toUTC().toString("yyyy-MM-ddThh:mm:ssZ"));
}
break;
}

case QVariant::ByteArray:
{
if (needKey)
m_pXmlWriter->writeTextElement("key", sName);
m_pXmlWriter->writeTextElement("data",
vValue.toByteArray().toBase64().data());
if (!vValue.toByteArray().isNull())
{
if (needKey)
m_pXmlWriter->writeTextElement("key", sName);
m_pXmlWriter->writeTextElement("data",
vValue.toByteArray().toBase64().data());
}
break;
}

Expand Down

0 comments on commit 4fee6b1

Please sign in to comment.