From 369cbd744ed06b3e01fe7a2e6a86ea4d85250231 Mon Sep 17 00:00:00 2001 From: Ezio Melotti Date: Mon, 13 Feb 2012 20:36:55 +0200 Subject: Fix an index, add more tests, avoid raising errors for unknown declarations, and clean up comments. --- Lib/HTMLParser.py | 5 +++-- Lib/test/test_htmlparser.py | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Lib/HTMLParser.py b/Lib/HTMLParser.py index 6cc9ff1..f230c5f 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 c15bb66..6667512 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 $ ')]) -- cgit v0.12