fix: handle names with endings that might parse as versions better (#4897)

* fix: Use the doc name matched by fuzzy_find_documents when rendering

Fixes #4855

* Follow suggestion by @rjsparks

* fix: handle names with endings that might parse as versions better

Co-authored-by: Lars Eggert <lars@eggert.org>
This commit is contained in:
Robert Sparks 2022-12-20 08:16:08 -06:00 committed by GitHub
parent 82bb7c81d2
commit 0f35f5df3a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -810,22 +810,20 @@ def document_html(request, name, rev=None):
if num_found > 1:
raise Http404("Multiple documents matched: %s" % name)
if found.matched_name.startswith('rfc') and name != found.matched_name:
return redirect('ietf.doc.views_doc.document_html', name=found.matched_name)
doc = found.documents.get()
rev = found.matched_rev
if doc.is_rfc() and rev is None:
if not name.startswith('rfc'):
return redirect('ietf.doc.views_doc.document_html', name=doc.canonical_name())
if found.matched_rev or found.matched_name.startswith('rfc'):
rev = found.matched_rev
else:
rev = doc.rev
if rev:
doc = doc.history_set.filter(rev=rev).first() or doc.fake_history_obj(rev)
if not os.path.exists(doc.get_file_name()):
raise Http404("File not found: %s" % doc.get_file_name())
return document_main(request, name, rev=rev, document_html=True)
return document_main(request, name=doc.name, rev=doc.rev if not doc.is_rfc() else None, document_html=True)
def document_pdfized(request, name, rev=None, ext=None):