[New-bugs-announce] [issue7626] Entity references without semicolon in HTMLParser

Stefan Schweizer report at bugs.python.org
Sun Jan 3 21:13:29 CET 2010

New submission from Stefan Schweizer <steve.schweizer at gmail.com>:

HTMLParser should only handle entity references that are terminated with a semicolon. I know that the semicolon can be omitted in some cases (http://www.w3.org/TR/html4/charset.html#h-5.3) and that some browsers are more tolerant, but the following example causes some odd output:

>>> import HTMLParser
>>> class EntityrefParser(HTMLParser.HTMLParser):
...     def handle_data(self, data):
...         print "handle_data '%s'" % data
...     def handle_entityref(self, name):
...         print "handle_entityref '%s'" % name
>>> p = EntityrefParser()
>>> p.feed("<p>spam&eggs are delicious</p>")

Expected Result:
handle_data 'spam&eggs are delicious'

Actual Result:
handle_data 'spam'
handle_entityref 'eggs'
handle_data ' are delicious'

components: Library (Lib)
messages: 97177
nosy: stefan.schweizer
severity: normal
status: open
title: Entity references without semicolon in HTMLParser
type: behavior
versions: Python 2.6

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list