Skip to content
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

Ensure incoming IRIs have either schemes or authorities #69

Open
agates opened this issue Sep 20, 2024 · 1 comment
Open

Ensure incoming IRIs have either schemes or authorities #69

agates opened this issue Sep 20, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@agates
Copy link
Collaborator

agates commented Sep 20, 2024

Need to check for non-empty scheme OR non-empty authority. Don't need both.

Existing code:

if rfc3987.match(podping_write.iri, "IRI"):
await unprocessed_iri_queue.put(podping_write)

@agates agates self-assigned this Sep 20, 2024
@agates agates added the enhancement New feature or request label Sep 20, 2024
@agates
Copy link
Collaborator Author

agates commented Sep 20, 2024

>>> rfc3987.parse("https://example.com/feed.xml", "IRI")
{'scheme': 'https', 'authority': 'example.com', 'path': '/feed.xml', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html", "IRI")
{'scheme': 'ipfs', 'authority': 'bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq', 'path': '/wiki/Vincent_van_Gogh.html', 'query': None, 'fragment': None}
>>> rfc3987.parse("://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html", "IRI")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/agates/.cache/pypoetry/virtualenvs/podping-hivewriter-GQ5UIonf-py3.10/lib/python3.10/site-packages/rfc3987.py", line 462, in parse
    raise ValueError('%r is not a valid %r.' % (string, rule))
ValueError: '://bafybeiemxf5abjwjbikoz4mc3a3dla6ual3jsgpdr4cjr3oz3evfyavhwq/wiki/Vincent_van_Gogh.html' is not a valid 'IRI'.
>>> rfc3987.parse("ipfs://", "IRI")
{'scheme': 'ipfs', 'authority': '', 'path': '', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs:test", "IRI")
{'scheme': 'ipfs', 'authority': None, 'path': 'test', 'query': None, 'fragment': None}
>>> rfc3987.parse("ipfs:test/example", "IRI")
{'scheme': 'ipfs', 'authority': None, 'path': 'test/example', 'query': None, 'fragment': None}
>>> rfc3987.parse("urn:btih:testing", "IRI")
{'scheme': 'urn', 'authority': None, 'path': 'btih:testing', 'query': None, 'fragment': None}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant