diff --git a/django/contrib/comments/views/utils.py b/django/contrib/comments/views/utils.py
index c5c900d..8b729d2 100644
a
|
b
|
def confirmation_view(template, doc="Display a confirmation view."):
|
39 | 39 | if 'c' in request.GET: |
40 | 40 | try: |
41 | 41 | comment = comments.get_model().objects.get(pk=request.GET['c']) |
42 | | except ObjectDoesNotExist: |
| 42 | except (ObjectDoesNotExist, ValueError): |
43 | 43 | pass |
44 | 44 | return render_to_response(template, |
45 | 45 | {'comment': comment}, |
diff --git a/tests/regressiontests/comment_tests/tests/comment_view_tests.py b/tests/regressiontests/comment_tests/tests/comment_view_tests.py
index 192131b..bb0b46e 100644
a
|
b
|
class CommentViewTests(CommentTestCase):
|
219 | 219 | location = response["Location"] |
220 | 220 | match = re.search(r"^http://testserver/somewhere/else/\?foo=bar&c=\d+$", location) |
221 | 221 | self.failUnless(match != None, "Unexpected redirect location: %s" % location) |
222 | | |
223 | | No newline at end of file |
| 222 | |
| 223 | def testCommentDoneReSubmitWithInvalidParams(self): |
| 224 | """ |
| 225 | If the comment-done url is resubmitted with some invalid data |
| 226 | ie mainly some non-integer, then a UnicodeEncodeError (a sub-class |
| 227 | of ValueError). |
| 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 | new_location = location + u"\ufffd" |
| 235 | x = lambda : self.client.get(new_location) |
| 236 | try: |
| 237 | self.assertRaises(ValueError, x) |
| 238 | except AssertionError: |
| 239 | # An exception shouldn't be raised. |
| 240 | # Hope there was a assertNotRaises |
| 241 | pass |