python-validators/validators

allow ptc-encoded entities in fragment

conitrade-as opened this issue · 0 comments

In #305 the fragment matching was improved. However, the current regex does not allow pct-encoded entities (see https://datatracker.ietf.org/doc/html/rfc3986#section-3.5) to be present.

The RFC states that:

  • fragment = *( pchar / "/" / "?" )
  • pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
  • pct-encoded = "%" HEXDIG HEXDIG

The used regular expression does not match the following valid example:

import re
fragment = '2022%201040%20(Cornelius%20Morgan%20G).pdf'
re.fullmatch(r"[0-9a-zA-Z?/:@\-._~!$&'()*+,;=]*", fragment)