Issue 13711: html.parser.HTMLParser doesn't parse tags in comments in scripts correctly (original) (raw)

Created on 2012-01-04 13:26 by turion, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
htmlparserbug.py turion,2012-01-04 13:26 Script demonstrating the bug
") parser_instance.handle_endtag("script", []) Instead, it calls: parser_instance.handle_starttag("script", []) parser_instance.handle_data(" Encountered an end tag: script [0]: http://docs.python.org/dev/library/html.parser.html#example-html-parser-application
Messages (8)
msg150603 - (view) Author: Manuel Bärenz (turion) Date: 2012-01-04 13:26
I've attached a script which demonstrates the bug. When feeding a ") It should call: parser_instance.handle_starttag("script", []) parser_instance.handle_data("") parser_instance.handle_endtag("td", []) parser_instance.handle_endtag("script", [])
msg150608 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-01-04 14:42
I believe this was fixed recently as part of issue 670664. Ezio will know for sure.
msg150611 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-01-04 15:02
Yep, this was fixed in #670664. With the development version of Python (AFAIK the fix has not be released yet) and the example parser found in the doc[0] I get this: >>> parser = MyHTMLParser() >>> parser.feed('') Encountered a start tag: script Encountered some data:
msg150614 - (view) Author: Manuel Bärenz (turion) Date: 2012-01-04 16:19
Great! Thank you!
History
Date User Action Args
2022-04-11 14:57:25 admin set github: 57920
2012-01-04 16:19:16 turion set messages: +
2012-01-04 15:02:17 ezio.melotti set status: open -> closedsuperseder: HTMLParser.py - more robust SCRIPT tag parsingmessages: + assignee: ezio.melottiresolution: duplicatestage: resolved
2012-01-04 14:42:30 r.david.murray set messages: +
2012-01-04 14:28:47 turion set messages: +
2012-01-04 14:25:35 turion set messages: +
2012-01-04 13:55:44 r.david.murray set nosy: + ezio.melotti, r.david.murraymessages: +
2012-01-04 13:38:27 turion set messages: +
2012-01-04 13:26:46 turion create