Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion feedparser/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@ def _parse_file_inplace(
saxparser.parse(source)
except xml.sax.SAXException as e:
result["bozo"] = 1
result["bozo_exception"] = feed_parser.exc or e
result["bozo_exception"] = e
use_strict_parser = False
else:
if feed_parser.bozo:
result["bozo"] = 1
result["bozo_exception"] = feed_parser.exc

# The loose XML parser will be tried if the strict XML parser was not used
# (or if it failed to parse the feed).
Expand Down
6 changes: 5 additions & 1 deletion tests/illformed/always_strip_doctype.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://site.invalid/">
<!--
Description: unstripped invalid doctype
Expect: not bozo and feed['title'] == 'found'
Expect: feed['title'] == 'found'
--><!--
The Expect-line above doesn't check if the bozo bit is set, because it depends
on the XML parser used: libxml2 issues an error for the invalid doctype, while
Expat does not.
-->
<rss>
<channel>
Expand Down