fix: Handle RFC names that are not all lowercase or have spaces (#4650)

* fix: Correctly handle RFC names that are not all lowercase or have spaces

Fixes #4576

* Address review comments
This commit is contained in:
Lars Eggert 2022-11-06 12:26:26 +00:00 committed by GitHub
parent af17d6481a
commit a3fc57bfb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1293,6 +1293,8 @@ def fuzzy_find_documents(name, rev=None):
document.
"""
# Handle special case name formats
if re.match(r"^\s*rfc", name, flags=re.IGNORECASE):
name = re.sub(r"\s+", "", name.lower())
if name.startswith('rfc0'):
name = "rfc" + name[3:].lstrip('0')
if name.startswith('review-') and re.search(r'-\d\d\d\d-\d\d$', name):
@ -1303,8 +1305,6 @@ def fuzzy_find_documents(name, rev=None):
rev = rev[-2:]
if re.match("^[0-9]+$", name):
name = f'rfc{name}'
if re.match("^[Rr][Ff][Cc] [0-9]+$",name):
name = f'rfc{name[4:]}'
# see if we can find a document using this name
docs = Document.objects.filter(docalias__name=name, type_id='draft')