mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 03:13:02 +00:00
Fix RSS feed not handling None values (#569)
Previously, the 'sanitize' function would throw an error when 'text' was None. This commit fixes the issue by adding a check to handle the case where 'text' is None, returning an empty string instead. Closes #568
This commit is contained in:
parent
dc9799cc53
commit
560769f068
2 changed files with 7 additions and 0 deletions
|
@ -16,6 +16,8 @@ class FeedContext:
|
|||
|
||||
|
||||
def sanitize(text: str):
|
||||
if not text:
|
||||
return ''
|
||||
# remove control characters
|
||||
valid_chars = ['\n', '\r', '\t']
|
||||
return ''.join(ch for ch in text if ch in valid_chars or unicodedata.category(ch)[0] != 'C')
|
||||
|
|
|
@ -7,6 +7,8 @@ from django.urls import reverse
|
|||
|
||||
from bookmarks.tests.helpers import BookmarkFactoryMixin
|
||||
from bookmarks.models import FeedToken, User
|
||||
from bookmarks.feeds import sanitize
|
||||
|
||||
|
||||
|
||||
def rfc2822_date(date):
|
||||
|
@ -112,6 +114,9 @@ class FeedsTestCase(TestCase, BookmarkFactoryMixin):
|
|||
self.assertContains(response, f'<title>test\n\r\ttitle</title>', count=1)
|
||||
self.assertContains(response, f'<description>test\n\r\tdescription</description>', count=1)
|
||||
|
||||
def test_sanitize_with_none_text(self):
|
||||
self.assertEqual('', sanitize(None))
|
||||
|
||||
def test_unread_returns_404_for_unknown_feed_token(self):
|
||||
response = self.client.get(reverse('bookmarks:feeds.unread', args=['foo']))
|
||||
|
||||
|
|
Loading…
Reference in a new issue