From 0f35f5df3aa365b91a55563465997844a35507da Mon Sep 17 00:00:00 2001 From: Robert Sparks Date: Tue, 20 Dec 2022 08:16:08 -0600 Subject: [PATCH] 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 --- ietf/doc/views_doc.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/ietf/doc/views_doc.py b/ietf/doc/views_doc.py index da5c9bfbd..3b7ccb4f2 100644 --- a/ietf/doc/views_doc.py +++ b/ietf/doc/views_doc.py @@ -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):