Skip to content

Status-change RFC name checks use unanchored 1-4 digit patterns #12142

Done

Description

@rjsparks

ietf/doc/views_status_change.py checks RFC names with patterns limited to 1-4 digits (line numbers as of 3be4aca):

443:  if re.match(r'\d{1,4}',v):                v = 'rfc'+v
460:  if not re.match(r'(?i)rfc\d{1,4}',key):   errors.append(...)
564:  if not re.match("(?i)rfc[0-9]{1,4}",name): raise Http404

These accept rfc10008 today only because re.match doesn't require the pattern to reach the end of the string: it matches the first four digits and ignores the rest. The same gap means they also accept input like rfc1234junk, which is caught later only because the Document lookup fails. So nothing is broken, but the checks don't validate what they appear to. A cleanup that anchors them ($ or re.fullmatch) without widening the digit count would make /doc/start-rfc-status-change/rfc10008/ return 404 and make the status-change relation form reject every 5-digit RFC.

Replace all three with anchored, unbounded patterns, such as re.fullmatch(r"\d+", v) and re.fullmatch(r"(?i)rfc\d+", ...), and add a test that uses a 5-digit RFC.

Part of #10000.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions