From 17fe4d526bb786d2b135d6ca31bee6adf7e57c0f Mon Sep 17 00:00:00 2001 From: maybe-hello-world Date: Sun, 23 Jul 2023 03:26:10 +0000 Subject: [PATCH] fix: return 404 for rfc revision for bibtex --- ietf/doc/tests.py | 11 ++++++----- ietf/doc/views_doc.py | 5 +++-- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/ietf/doc/tests.py b/ietf/doc/tests.py index 8819861a36..65fb80a158 100644 --- a/ietf/doc/tests.py +++ b/ietf/doc/tests.py @@ -2008,6 +2008,12 @@ def test_document_bibtex(self): # self.assertNotIn('day', entry) + # test for incorrect case - revision for RFC + rfc = WgRfcFactory(name="rfc0000") + url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=rfc.name, rev='00')) + r = self.client.get(url) + self.assertEqual(r.status_code, 404) + april1 = IndividualRfcFactory.create( stream_id = 'ise', states = [('draft','rfc'),('draft-iesg','pub')], @@ -2048,11 +2054,6 @@ def test_document_bibtex(self): # self.assertNotIn('doi', entry) - # check for non-existent revision - url = urlreverse('ietf.doc.views_doc.document_bibtex', kwargs=dict(name=draft.name, rev='99')) - r = self.client.get(url) - self.assertEqual(r.status_code, 404) - def test_document_bibxml(self): draft = IndividualDraftFactory.create() docname = '%s-%s' % (draft.name, draft.rev) diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index fb4079e9d7..a14026d434 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -1083,6 +1083,9 @@ def document_history(request, name): def document_bibtex(request, name, rev=None): + if name.startswith('rfc') and rev is not None: + raise Http404() + # Make sure URL_REGEXPS did not grab too much for the rev number if rev != None and len(rev) != 2: mo = re.search(r"^(?P[0-9]{1,2})-(?P[0-9]{2})$", rev) @@ -1106,8 +1109,6 @@ def document_bibtex(request, name, rev=None): if rev == h.rev: doc = h break - else: - raise Http404() if doc.is_rfc(): # This needs to be replaced with a lookup, as the mapping may change