From 0de1e84821146b5103af9ec22dc023050d0cf68e Mon Sep 17 00:00:00 2001 From: randomdan Date: Wed, 20 Mar 2013 14:12:04 +0000 Subject: Really dirty hack to make libxmlpp not crash with HTML docs --- project2/xml/xmlDocumentCache.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/project2/xml/xmlDocumentCache.cpp b/project2/xml/xmlDocumentCache.cpp index 96848e7..cbc13ed 100644 --- a/project2/xml/xmlDocumentCache.cpp +++ b/project2/xml/xmlDocumentCache.cpp @@ -50,6 +50,13 @@ class XmlDocumentCachePopulator : public CurlCompleteCallback { XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url, boost::bind(helperThrow, std::string(xmlGetLastError()->message)))); } + + // Dirty hack alert + // xmlpp doesn't play nicely with HTML documents... + // sooo ummm, lie and hope it doesn't break something else + doc->type = XML_DOCUMENT_NODE; + // end hack + XmlDocumentCache::documents.insert(XmlDocumentCache::Documents::value_type(url, boost::bind(helperReturnDocument, XmlDocumentCache::DocumentPtr(new xmlpp::Document(doc))))); Logger()->messagebf(LOG_DEBUG, "Download of '%s' completed, stored", url); @@ -101,6 +108,7 @@ class XmlDocumentCacheClearer : public ComponentLoader { { Logger()->messagef(LOG_DEBUG, "%s: Clearing XML document cache", __PRETTY_FUNCTION__); XmlDocumentCache::documents.clear(); + Logger()->messagef(LOG_DEBUG, "%s: Cleared XML document cache", __PRETTY_FUNCTION__); } }; DECLARE_CUSTOM_COMPONENT_LOADER("XmlDocumentCacheClearer", XmlDocumentCacheClearer, XmlDocumentCacheClearer, ComponentLoader); -- cgit v1.2.3