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