This commit is contained in:
vl 2010-05-17 15:27:56 +02:00
commit 95ec42ee71
3 changed files with 30 additions and 12 deletions

View file

@ -2625,7 +2625,7 @@ void CGroupHTML::handle ()
_URL = home(); _URL = home();
string finalUrl; string finalUrl;
lookupLocalFile (finalUrl, _URL.c_str(), true); bool isLocal = lookupLocalFile (finalUrl, _URL.c_str(), true);
// Reset the title // Reset the title
if(_TitlePrefix.empty()) if(_TitlePrefix.empty())
@ -2664,7 +2664,12 @@ void CGroupHTML::handle ()
C3WSmartPtr uri = HTParse(finalUrl.c_str(), NULL, PARSE_ALL); C3WSmartPtr uri = HTParse(finalUrl.c_str(), NULL, PARSE_ALL);
// Create an anchor // Create an anchor
#ifdef NL_OS_WINDOWS
if ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL) if ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL)
#else
// temporarily disable local URL's until LibWWW can be replaced.
if (isLocal || ((_LibWWW->Anchor = HTAnchor_findAddress(uri)) == NULL))
#endif
{ {
browseError((string("The page address is malformed : ")+(const char*)uri).c_str()); browseError((string("The page address is malformed : ")+(const char*)uri).c_str());
} }

View file

@ -14,9 +14,13 @@
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
* Completely implemented in xml_auto_ptr.h
*/
#include "stdpch.h" #include "stdpch.h"
/*
#include "xml_auto_ptr.h" #include "xml_auto_ptr.h"
#include <libxml/parser.h> #include <libxml/parser.h>
@ -45,10 +49,4 @@ CXMLAutoPtr &CXMLAutoPtr::operator = (const char *other)
return *this; return *this;
} }
*/

View file

@ -28,7 +28,7 @@ class CXMLAutoPtr
public: public:
CXMLAutoPtr(const char *value = NULL) : _Value(value) {} CXMLAutoPtr(const char *value = NULL) : _Value(value) {}
CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {} CXMLAutoPtr(const unsigned char *value) : _Value((const char *) value) {}
~CXMLAutoPtr(); ~CXMLAutoPtr() { destroy(); }
operator const char *() const { return _Value; } operator const char *() const { return _Value; }
operator bool() const { return _Value != NULL; } operator bool() const { return _Value != NULL; }
operator std::string() const { return std::string(_Value); } operator std::string() const { return std::string(_Value); }
@ -36,7 +36,14 @@ public:
operator const unsigned char *() const { return (const unsigned char *) _Value; } operator const unsigned char *() const { return (const unsigned char *) _Value; }
const char operator * () const { nlassert(_Value); return *_Value; } const char operator * () const { nlassert(_Value); return *_Value; }
/// NB : This remove previous owned pointer with xmlFree /// NB : This remove previous owned pointer with xmlFree
CXMLAutoPtr &operator = (const char *other); CXMLAutoPtr &operator = (const char *other)
{
if (other == _Value) return *this;
destroy();
_Value = other;
return *this;
}
CXMLAutoPtr &operator = (const unsigned char *other) CXMLAutoPtr &operator = (const unsigned char *other)
{ {
*this = (const char *) other; *this = (const char *) other;
@ -47,7 +54,15 @@ public:
private: private:
const char *_Value; const char *_Value;
private: private:
void destroy(); void destroy()
{
if (_Value)
{
xmlFree(const_cast<char *>(_Value));
_Value = NULL;
}
}
// We'd rather avoid problems // We'd rather avoid problems
CXMLAutoPtr(const CXMLAutoPtr &/* other */) CXMLAutoPtr(const CXMLAutoPtr &/* other */)
{ {