Skip to content

Match empty path without using line begin/end #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 22, 2023

Conversation

handrews
Copy link
Contributor

@handrews handrews commented Feb 18, 2023

Fixes #88: This change allows correctly recognizing URIs with a scheme, but no authority and an empty path (and possibly non-empty query or fragment) as absolute. The "about:" URI scheme is a scheme that allows such syntax, as show in the linked issue.

This uses a non-capturing group as it was unclear if any code anywhere else was relying on capture group numbering from regexes that include the empty path regex. I'm happy to change it if anyone has a better idea.

---------- coverage: platform darwin, python 3.12.0-alpha-5 ----------
Name                                                             Stmts   Miss  Cover
------------------------------------------------------------------------------------
.tox/py312/lib/python3.12/site-packages/rfc3986/__init__.py         16      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/_mixin.py          112      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/abnf_regexp.py      63      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/api.py              15      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/builder.py          66      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/compat.py           10      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/exceptions.py       44      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/iri.py              50      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/misc.py             31      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/normalizers.py      80      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/parseresult.py     167      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/uri.py              30      0   100%
.tox/py312/lib/python3.12/site-packages/rfc3986/validators.py      128      0   100%
------------------------------------------------------------------------------------
TOTAL                                                              812      0   100%

Required test coverage of 100% reached. Total coverage: 100.00%
2850 passed, 4947 warnings in 3.00s
.pkg: _exit> python /Users/handrews/dev/.venv/lib/python3.8/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__
py312: OK ✔ in 3.89 seconds
lint: commands[0]> black -l 78 -t py37 src/rfc3986 tests/
All done! ✨ 🍰 ✨
25 files left unchanged.
lint: commands[1]> flake8 src/rfc3986
  py37: OK (4.29=setup[1.05]+cmd[3.24] seconds)
  py38: OK (3.91=setup[0.69]+cmd[3.23] seconds)
  py39: OK (4.66=setup[1.44]+cmd[3.22] seconds)
  py310: OK (3.80=setup[0.70]+cmd[3.10] seconds)
  py311: OK (3.86=setup[0.68]+cmd[3.18] seconds)
  py312: OK (3.89=setup[0.67]+cmd[3.22] seconds)
  lint: OK (0.61=setup[0.01]+cmd[0.13,0.47] seconds)
  congratulations :) (25.12 seconds)

This change allows correclty recognizing URIs with a scheme, but
no authority and an empty path (and possibly non-empty query or
fragment) as absolute.  The "about:" URI scheme is a scheme
that allows such syntax.

This uses a non-capturing group as it was unclear if any code
anywhere else was relying on capture group numbering from regexes
that include the empty path regex.
@handrews
Copy link
Contributor Author

Also, I'm assuming nothing was relying on the line begin/end since everything still passes, but do please let me know if I'm missing something.

@handrews
Copy link
Contributor Author

On further thought it seems like this syntax is not legal at all. Closing this PR unless/until there's a definitive judgement that it's needed in the linked issue.

@handrews handrews closed this Feb 18, 2023
@handrews
Copy link
Contributor Author

I confused myself, and I think I have now unconfused myself and this PR is actually relevant after all.

Apologies for the noise.

@handrews handrews reopened this Feb 18, 2023
@sigmavirus24 sigmavirus24 merged commit 1957c2b into python-hyper:main Feb 22, 2023
@sigmavirus24
Copy link
Collaborator

Thank you! No need to apologize for the noise, didn't notice it

@handrews handrews deleted the empty branch February 22, 2023 04:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PATH_EMPTY regex does not actually match empty path
2 participants