Skip to content

Commit

Permalink
Fix content:encoded bug where it replaces the body
Browse files Browse the repository at this point in the history
Separate 403 and 410 handling
  • Loading branch information
xurble committed Aug 1, 2023
1 parent 2503220 commit 4492314
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

### 1.0.7
- Fixes a bug that could result in the wrong body being set on items with a <content:encoded> element
- Separates the handling of 403 and 410 result codes

### 1.0.6
- Fixes a bug preventing existing enclosures being updated when re-reading a feed
- Adds support for the 'medium' attribute on <content:encoded> items.
Expand Down
18 changes: 7 additions & 11 deletions feeds/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ def read_feed(source_feed, output=NullOutput()):
#not found
source_feed.interval += 120
source_feed.last_result = "The feed could not be found"
elif ret.status_code == 403 or ret.status_code == 410: #Forbidden or gone

elif ret.status_code == 410: # Gone
source_feed.last_result = "Feed has gone away and says it isn't coming back."
source_feed.live = False
elif ret.status_code == 403: # Forbidden
if "Cloudflare" in ret.text or ("Server" in ret.headers and "cloudflare" in ret.headers["Server"]):

if source_feed.is_cloudflare and proxy is not None:
Expand All @@ -225,7 +227,6 @@ def read_feed(source_feed, output=NullOutput()):
else:
source_feed.last_result = "Feed is no longer accessible."
source_feed.live = False


elif ret.status_code >= 400 and ret.status_code < 500:
#treat as bad request
Expand Down Expand Up @@ -483,22 +484,17 @@ def parse_feed_xml(source_feed, feed_content, output):

# we are going to take the longest
body = ""

if hasattr(e, "content"):
for c in e.content:
if len(c.value) > len(body):
body = c.value


if hasattr(e, "summary"):
if len(e.summary) > len(body):
body = e.summary

if hasattr(e, "summary_detail"):
if len(e.summary_detail.value) > len(body):
if len(e.summary_detail.value) >= len(body):
body = e.summary_detail.value

if hasattr(e, "description"):
if len(e.description) > len(body):
if len(e.description) >= len(body):
body = e.description


Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setuptools.setup(
name='django-feed-reader',
version='1.0.6',
version='1.0.7',
description='An RSS feed reading library for Django.',
long_description=long_description,
long_description_content_type='text/markdown',
Expand Down

0 comments on commit 4492314

Please sign in to comment.