Skip to content

Commit

Permalink
fix: return 404 for rfc revision for bibtex
Browse files Browse the repository at this point in the history
  • Loading branch information
maybe-hello-world committed Jul 23, 2023
1 parent 585badf commit 17fe4d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 6 additions & 5 deletions ietf/doc/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions ietf/doc/views_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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<m>[0-9]{1,2})-(?P<n>[0-9]{2})$", rev)
Expand All @@ -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
Expand Down

0 comments on commit 17fe4d5

Please sign in to comment.