From: richardbarran Date: Mon, 19 Oct 2009 20:27:39 +0000 (+0000) Subject: Escape any text sent by users (protection against cross-site scripting). X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=1c30951575e673a9714b519f4a2f89f261a57120;p=django-jqchat.git Escape any text sent by users (protection against cross-site scripting). git-svn-id: http://django-jqchat.googlecode.com/svn/trunk@12 8369a704-5b4a-11de-992f-fdd7e25b9163 --- diff --git a/jqchat/tests.py b/jqchat/tests.py index 11e081b..2b8e4e0 100644 --- a/jqchat/tests.py +++ b/jqchat/tests.py @@ -201,6 +201,20 @@ class AJAXPostTest(TestCase): # No messages added to the 4 already defined. self.assert_(len(messages) == 4) + def test_XSS(self): + """Check that chat is protected against cross-site scripting (by disabling html tags).""" + + response = self.client.post('/jqchat/room/1/ajax/', {'time': 0, + 'action': 'postmsg', + 'message': ''}) + self.assert_(response.status_code == 200, response.status_code) + + payload = simplejson.loads(response.content) + messages = payload['messages'] + self.assert_('<script>' in messages[-1]['text']) + self.assert_('