rfc3986 icon indicating copy to clipboard operation
rfc3986 copied to clipboard

PATH_EMPTY regex does not actually match empty path

Open milo-minderbinder opened this issue 3 years ago • 0 comments

https://github.com/python-hyper/rfc3986/blob/164073434fe530e14ceca4ff6a0683e23e2fde48/src/rfc3986/abnf_regexp.py#L153

The PATH_EMPTY regex won't ever match anything when embedded within another regex, as it is in several places like here: https://github.com/python-hyper/rfc3986/blob/164073434fe530e14ceca4ff6a0683e23e2fde48/src/rfc3986/abnf_regexp.py#L184-L190

This causes the URIReference.is_absolute() method to return an incorrect result for a URI with a scheme but no path. For example, http: (or even http:?q=v) is an absolute URI according to section-4.3, but URIReference.from_string('http:').is_absolute() returns False.

There are likely other places where this causes intended matches to fail, but I have not tried to investigate further. It's a little odd looking, but a fix that would probably work is just to change the value of PATH_EMPTY to an empty string.

milo-minderbinder avatar Apr 22 '22 06:04 milo-minderbinder