python-validators / validators

Python Data Validation for Humans™.
MIT License
977 stars 155 forks source link

allow ptc-encoded entities in fragment #316

Closed conitrade-as closed 1 year ago

conitrade-as commented 1 year ago

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:

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)