1.1 --- a/libxml2dom/macrolib/macrolib.py Sat Jun 01 17:01:05 2013 +0200
1.2 +++ b/libxml2dom/macrolib/macrolib.py Thu Jul 18 17:54:37 2013 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 DOM macros for virtual libxml2mod node methods and properties.
1.6
1.7 -Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU Lesser General Public License as published by the Free
1.12 @@ -595,8 +595,11 @@
1.13 context = libxml2mod.xmlCreateFileParserCtxt(s)
1.14 return _parseXML(context, unfinished, validate, remote)
1.15 else:
1.16 - return libxml2mod.htmlReadFile(s, htmlencoding,
1.17 + d = libxml2mod.htmlReadFile(s, htmlencoding,
1.18 HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | html_net_flag(remote))
1.19 + if d is None:
1.20 + raise LSException(LSException.PARSE_ERR, DOMError(DOMError.SEVERITY_FATAL_ERROR, get_parse_error_message()))
1.21 + return d
1.22
1.23 def parseString(s, html=0, htmlencoding=None, unfinished=0, validate=0, remote=0):
1.24 if not html:
1.25 @@ -605,8 +608,11 @@
1.26 else:
1.27 # NOTE: URL given as None.
1.28 html_url = None
1.29 - return libxml2mod.htmlReadMemory(s, len(s), html_url, htmlencoding,
1.30 + d = libxml2mod.htmlReadMemory(s, len(s), html_url, htmlencoding,
1.31 HTML_PARSE_NOERROR | HTML_PARSE_NOWARNING | html_net_flag(remote))
1.32 + if d is None:
1.33 + raise LSException(LSException.PARSE_ERR, DOMError(DOMError.SEVERITY_FATAL_ERROR, get_parse_error_message()))
1.34 + return d
1.35
1.36 def parseURI(uri, html=0, htmlencoding=None, unfinished=0, validate=0, remote=0):
1.37 if not html:
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/tests/test_bad_html.py Thu Jul 18 17:54:37 2013 +0200
2.3 @@ -0,0 +1,9 @@
2.4 +#!/usr/bin/env python
2.5 +
2.6 +import libxml2dom
2.7 +
2.8 +html = "<bad"
2.9 +
2.10 +print libxml2dom.parseString(html, html=True)
2.11 +
2.12 +# vim: tabstop=4 expandtab shiftwidth=4