Ticket #12151: 12151-kmt.diff

File 12151-kmt.diff, 1.8 KB (added by Karen Tracey, 14 years ago)
  • django/contrib/comments/views/utils.py

     
    3939        if 'c' in request.GET:
    4040            try:
    4141                comment = comments.get_model().objects.get(pk=request.GET['c'])
    42             except ObjectDoesNotExist:
     42            except (ObjectDoesNotExist, ValueError):
    4343                pass
    4444        return render_to_response(template,
    4545            {'comment': comment},
  • tests/regressiontests/comment_tests/tests/comment_view_tests.py

     
    219219        location = response["Location"]       
    220220        match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location)
    221221        self.failUnless(match != None, "Unexpected redirect location: %s" % location)
    222        
    223  No newline at end of file
     222
     223    def testCommentDoneReSubmitWithInvalidParams(self):
     224        """
     225        Tests that attempting to retrieve the location specified in the
     226        post redirect, after adding some invalid data to the expected
     227        querystring it ends with, doesn't cause a server error.
     228        """
     229        a = Article.objects.get(pk=1)
     230        data = self.getValidData(a)
     231        data["comment"] = "This is another comment"
     232        response = self.client.post("/post/", data)
     233        location = response["Location"]
     234        broken_location = location + u"\ufffd"
     235        response = self.client.get(broken_location)
     236        self.assertEqual(response.status_code, 200)
Back to Top