X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Ffreenet%2Fidentityintroductionxml.cpp;h=f6b8a2e57717ea83f0347edfd44f79e418c629e6;hb=b88f50bfec6dbcd169bb8285e7c42b93baf52b6b;hp=e1a4eff0b86dabf56e33bf0ac62cb0db543210bc;hpb=d8f51eac91f86a1e00a05a5058a8fa9eb8732464;p=fms.git diff --git a/src/freenet/identityintroductionxml.cpp b/src/freenet/identityintroductionxml.cpp index e1a4eff..f6b8a2e 100644 --- a/src/freenet/identityintroductionxml.cpp +++ b/src/freenet/identityintroductionxml.cpp @@ -12,19 +12,14 @@ IdentityIntroductionXML::IdentityIntroductionXML() std::string IdentityIntroductionXML::GetXML() { - TiXmlDocument td; - TiXmlDeclaration *tdec=new TiXmlDeclaration("1.0","UTF-8",""); - TiXmlElement *tid; - TiXmlPrinter tp; + Poco::AutoPtr doc=new Poco::XML::Document; + Poco::AutoPtr root=doc->createElement("IdentityIntroduction"); - td.LinkEndChild(tdec); - tid=new TiXmlElement("IdentityIntroduction"); - td.LinkEndChild(tid); + doc->appendChild(root); - tid->LinkEndChild(XMLCreateCDATAElement("Identity",m_identity)); + root->appendChild(XMLCreateCDATAElement(doc,"Identity",m_identity)); - td.Accept(&tp); - return std::string(tp.CStr()); + return GenerateXML(doc); } void IdentityIntroductionXML::Initialize() @@ -35,34 +30,37 @@ void IdentityIntroductionXML::Initialize() const bool IdentityIntroductionXML::ParseXML(const std::string &xml) { FreenetSSK ssk; - TiXmlDocument td; - td.Parse(xml.c_str()); + bool parsed=false; + Poco::XML::DOMParser dp; - if(!td.Error()) - { - TiXmlElement *el; - TiXmlText *txt; - TiXmlHandle hnd(&td); + Initialize(); - Initialize(); + try + { + Poco::AutoPtr doc=dp.parseString(FixCDATA(xml)); + Poco::XML::Element *root=XMLGetFirstChild(doc,"IdentityIntroduction"); + Poco::XML::Element *txt=NULL; - txt=hnd.FirstChild("IdentityIntroduction").FirstChild("Identity").FirstChild().ToText(); + txt=XMLGetFirstChild(root,"Identity"); if(txt) { - m_identity=txt->ValueStr(); + if(txt->firstChild()) + { + m_identity=SanitizeSingleString(txt->firstChild()->getNodeValue()); + } } + ssk.SetPublicKey(m_identity); if(ssk.ValidPublicKey()==false) { return false; } - return true; - + parsed=true; } - else + catch(...) { - return false; } -} \ No newline at end of file + return parsed; +}