Skip to content

Commit 72d0809

Browse files
committed
Pass raw data to feedparser. Fixes #59
1 parent 68e5a84 commit 72d0809

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Diff for: rss/bot.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -257,15 +257,9 @@ def _parse_json_entry(cls, feed_id: int, entry: dict[str, Any]) -> Entry:
257257
async def _parse_rss(
258258
cls, feed: Feed, resp: aiohttp.ClientResponse
259259
) -> tuple[Feed, list[Entry]]:
260-
try:
261-
content = await resp.text()
262-
except UnicodeDecodeError:
263-
try:
264-
content = await resp.text(encoding="utf-8", errors="ignore")
265-
except UnicodeDecodeError:
266-
content = str(await resp.read())[2:-1]
260+
content = await resp.read()
267261
headers = {"Content-Location": feed.url, **resp.headers, "Content-Encoding": "identity"}
268-
parsed_data = feedparser.parse(io.StringIO(content), response_headers=headers)
262+
parsed_data = feedparser.parse(io.BytesIO(content), response_headers=headers)
269263
if parsed_data.bozo:
270264
if not isinstance(parsed_data.bozo_exception, feedparser.ThingsNobodyCaresAboutButMe):
271265
raise parsed_data.bozo_exception

0 commit comments

Comments
 (0)