Skip to content

Commit 1a5aad5

Browse files
committed
tests: Add test for unescaped values in patch detail page
Add a test to check whether we are escaping values from the Patch model on the patch detail page. This test shouldn't be relied upon as proof that we've escaped everything correctly, but may help catch regressions. Signed-off-by: Andrew Donnellan <[email protected]> (backported from df80e69) Signed-off-by: Daniel Axtens <[email protected]>
1 parent 5cda060 commit 1a5aad5

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

patchwork/tests/test_detail.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,23 @@ def test_series_dropdown(self):
6666
response,
6767
reverse('series-mbox', kwargs={'series_id': series_.id}))
6868

69+
def test_escaping(self):
70+
# Warning: this test doesn't guarantee anything - it only tests some
71+
# fields
72+
unescaped_string = 'blah<b>TEST</b>blah'
73+
patch = create_patch()
74+
patch.diff = unescaped_string
75+
patch.commit_ref = unescaped_string
76+
patch.pull_url = unescaped_string
77+
patch.name = unescaped_string
78+
patch.msgid = unescaped_string
79+
patch.headers = unescaped_string
80+
patch.content = unescaped_string
81+
patch.save()
82+
requested_url = reverse('patch-detail', kwargs={'patch_id': patch.id})
83+
response = self.client.get(requested_url)
84+
self.assertNotIn('<b>TEST</b>'.encode('utf-8'), response.content)
85+
6986

7087
class CommentRedirectTest(TestCase):
7188

0 commit comments

Comments
 (0)