From: Ezio Melotti Date: Mon, 13 Feb 2012 18:36:55 +0000 (+0200) Subject: Fix an index, add more tests, avoid raising errors for unknown declarations, and... X-Git-Tag: v2.7.3rc1~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=369cbd744ed06b3e01fe7a2e6a86ea4d85250231;p=python Fix an index, add more tests, avoid raising errors for unknown declarations, and clean up comments. --- diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py index 6cc9ff13bf..f230c5f163 100644 --- a/Lib/HTMLParser.py +++ b/Lib/HTMLParser.py @@ -229,12 +229,13 @@ class HTMLParser(markupbase.ParserBase): if rawdata[i:i+2] != ' - gtpos = rawdata.find('>', 9) + gtpos = rawdata.find('>', i+9) if gtpos == -1: return -1 self.handle_decl(rawdata[i+2:gtpos]) @@ -427,7 +428,7 @@ class HTMLParser(markupbase.ParserBase): pass def unknown_decl(self, data): - self.error("unknown declaration: %r" % (data,)) + pass # Internal -- helper to remove special character quoting entitydefs = None diff --git a/Lib/test/test_htmlparser.py b/Lib/test/test_htmlparser.py index c15bb660e2..6667512785 100644 --- a/Lib/test/test_htmlparser.py +++ b/Lib/test/test_htmlparser.py @@ -215,6 +215,30 @@ text self._parse_error("" % dtd, + [('decl', 'DOCTYPE ' + dtd)]) + def test_declaration_junk_chars(self): self._run_check("", [('decl', 'DOCTYPE foo $ ')])