summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2014-03-21 16:07:32 (GMT)
committerChristian Mollekopf <chrigi_1@fastmail.fm>2014-03-21 16:07:32 (GMT)
commit85da145b3bdd0be29df23dff1c41ba9b2289bcf5 (patch)
treea330a35db1e8d0813d24faf713e8b72ea04da1b7
parentcb48f40745bf4017b3a11d7a61d36cda9139c4e3 (diff)
downloadlibkolabxml-85da145b3bdd0be29df23dff1c41ba9b2289bcf5.tar.gz
Validate serialized objects again.
We ensure that we can parse everything we serialize by parsing it again. This implies an overhead, but since reads are probably far more frequent than write and its generally anyways fast, I assume this is ok. The error reporting is as usual through Kolab::error().
-rw-r--r--src/kolabformat.cpp44
1 files changed, 35 insertions, 9 deletions
diff --git a/src/kolabformat.cpp b/src/kolabformat.cpp
index 10f5591..abd8f54 100644
--- a/src/kolabformat.cpp
+++ b/src/kolabformat.cpp
@@ -86,7 +86,10 @@ std::string writeEvent(const Kolab::Event &event, const std::string& productId)
{
Utils::clearErrors();
validate(event);
- return XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(event, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(event, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Event> >(result, false);
+ return result;
}
Kolab::Todo readTodo(const std::string& s, bool isUrl)
@@ -103,7 +106,10 @@ std::string writeTodo(const Kolab::Todo &event, const std::string& productId)
{
Utils::clearErrors();
validate(event);
- return XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(event, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(event, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Todo> >(result, false);
+ return result;
}
Journal readJournal(const std::string& s, bool isUrl)
@@ -120,7 +126,10 @@ std::string writeJournal(const Kolab::Journal &j, const std::string& productId)
{
Utils::clearErrors();
validate(j);
- return XCAL::serializeIncidence<XCAL::IncidenceTrait<Kolab::Journal> >(j, productId);
+ const std::string result = XCAL::serializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(j, productId);
+ //Validate
+ XCAL::deserializeIncidence< XCAL::IncidenceTrait<Kolab::Journal> >(result, false);
+ return result;
}
Kolab::Freebusy readFreebusy(const std::string& s, bool isUrl)
@@ -137,7 +146,9 @@ std::string writeFreebusy(const Freebusy &f, const std::string& productId)
{
Utils::clearErrors();
validate(f);
- return XCAL::serializeFreebusy<XCAL::IncidenceTrait<Kolab::Freebusy> >(f, productId);
+ const std::string result = XCAL::serializeFreebusy<XCAL::IncidenceTrait<Kolab::Freebusy> >(f, productId);
+ XCAL::deserializeIncidence<XCAL::IncidenceTrait<Kolab::Freebusy> >(result, false);
+ return result;
}
Kolab::Contact readContact(const std::string& s, bool isUrl)
@@ -154,7 +165,10 @@ std::string writeContact(const Contact &contact, const std::string& productId)
{
Utils::clearErrors();
validate(contact);
- return XCARD::serializeCard(contact, productId);
+ const std::string result = XCARD::serializeCard(contact, productId);
+ //Validate
+ XCARD::deserializeCard<Kolab::Contact>(result, false);
+ return result;
}
DistList readDistlist(const std::string& s, bool isUrl)
@@ -171,7 +185,10 @@ std::string writeDistlist(const DistList &list, const std::string& productId)
{
Utils::clearErrors();
validate(list);
- return XCARD::serializeCard(list, productId);
+ const std::string result = XCARD::serializeCard(list, productId);
+ //Validate
+ XCARD::deserializeCard<Kolab::DistList>(result, false);
+ return result;
}
Note readNote(const std::string& s, bool isUrl)
@@ -188,7 +205,10 @@ std::string writeNote(const Note &note, const std::string& productId)
{
Utils::clearErrors();
validate(note);
- return Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Note>(note, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::Note>(result, false);
+ return result;
}
File readFile(const std::string& s, bool isUrl)
@@ -205,7 +225,10 @@ std::string writeFile(const File &file, const std::string& productId)
{
Utils::clearErrors();
validate(file);
- return Kolab::KolabObjects::serializeObject<Kolab::File>(file, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::File>(file, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::File>(result, false);
+ return result;
}
Configuration readConfiguration(const std::string& s, bool isUrl)
@@ -222,7 +245,10 @@ std::string writeConfiguration(const Configuration &config, const std::string& p
{
Utils::clearErrors();
validate(config);
- return Kolab::KolabObjects::serializeObject< Kolab::Configuration >(config, productId);
+ const std::string result = Kolab::KolabObjects::serializeObject<Kolab::Configuration>(config, productId);
+ //Validate
+ Kolab::KolabObjects::deserializeObject<Kolab::Configuration>(result, false);
+ return result;
}