mirror of
https://github.com/sissbruecker/linkding
synced 2024-11-22 03:13:02 +00:00
Properly encode search query param (#587)
This commit is contained in:
parent
227cfdb063
commit
6355d8dff1
4 changed files with 89 additions and 1 deletions
|
@ -95,7 +95,7 @@
|
|||
props: {
|
||||
name: 'q',
|
||||
placeholder: 'Search for words or #tags',
|
||||
value: '{{ search.q|safe }}',
|
||||
value: input.value,
|
||||
tags: uniqueTags,
|
||||
mode: '{{ mode }}',
|
||||
linkTarget: '{{ request.user_profile.bookmark_link_target }}',
|
||||
|
|
|
@ -422,3 +422,31 @@ class BookmarkArchivedViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin
|
|||
|
||||
self.assertEqual(actions_form.attrs['action'],
|
||||
'/bookmarks/archived/action?q=%23foo&return_url=%2Fbookmarks%2Farchived%3Fq%3D%2523foo')
|
||||
|
||||
def test_encode_search_params(self):
|
||||
bookmark = self.setup_bookmark(description='alert(\'xss\')', is_archived=True)
|
||||
|
||||
url = reverse('bookmarks:archived') + '?q=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
self.assertContains(response, bookmark.url)
|
||||
|
||||
url = reverse('bookmarks:archived') + '?sort=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:archived') + '?unread=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:archived') + '?shared=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:archived') + '?user=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:archived') + '?page=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
|
|
@ -418,3 +418,31 @@ class BookmarkIndexViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||
|
||||
self.assertEqual(actions_form.attrs['action'],
|
||||
'/bookmarks/action?q=%23foo&return_url=%2Fbookmarks%3Fq%3D%2523foo')
|
||||
|
||||
def test_encode_search_params(self):
|
||||
bookmark = self.setup_bookmark(description='alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:index') + '?q=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
self.assertContains(response, bookmark.url)
|
||||
|
||||
url = reverse('bookmarks:index') + '?sort=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:index') + '?unread=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:index') + '?shared=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:index') + '?user=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:index') + '?page=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
|
|
@ -500,3 +500,35 @@ class BookmarkSharedViewTestCase(TestCase, BookmarkFactoryMixin, HtmlTestMixin):
|
|||
|
||||
self.assertEqual(actions_form.attrs['action'],
|
||||
'/bookmarks/shared/action?q=%23foo&return_url=%2Fbookmarks%2Fshared%3Fq%3D%2523foo')
|
||||
|
||||
def test_encode_search_params(self):
|
||||
self.authenticate()
|
||||
user = self.get_or_create_test_user()
|
||||
user.profile.enable_sharing = True
|
||||
user.profile.save()
|
||||
bookmark = self.setup_bookmark(description='alert(\'xss\')', shared=True)
|
||||
|
||||
url = reverse('bookmarks:shared') + '?q=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
self.assertContains(response, bookmark.url)
|
||||
|
||||
url = reverse('bookmarks:shared') + '?sort=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:shared') + '?unread=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:shared') + '?shared=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:shared') + '?user=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
||||
url = reverse('bookmarks:shared') + '?page=alert(%27xss%27)'
|
||||
response = self.client.get(url)
|
||||
self.assertNotContains(response, 'alert(\'xss\')')
|
||||
|
|
Loading…
Reference in a new issue