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

':' is being considered a valid relative URI #74

Open
Silvanoc opened this issue Oct 10, 2023 · 4 comments
Open

':' is being considered a valid relative URI #74

Silvanoc opened this issue Oct 10, 2023 · 4 comments
Assignees
Labels

Comments

@Silvanoc
Copy link

Silvanoc commented Oct 10, 2023

Describe the bug
The string ":" (simply a colon) is being considered a valid relative URI.
But, if I'm reading the specification right, it isn't a valid relative URI.

Expected result
uritools.isrelpath(":") returns False

Actual result
uritools.isrelpath(":") returns True

Reproduction steps

import uritools
print(uritools.isrelpath(":"))
@Silvanoc
Copy link
Author

Silvanoc commented Oct 10, 2023

For example, this alternative Python URI validator also rejects ':' as a valid relative URI.

@Silvanoc
Copy link
Author

This other alternative online validator is also rejecting it: https://0mg.github.io/tools/uri/

@tkem
Copy link
Owner

tkem commented Oct 24, 2023

@Silvanoc: Thanks for your interest! Regarding ":" used as an URI, this is - for better or worse - interpreted as a simple path, and therefore as a valid relative URI:

>>> uritools.urisplit(":")
SplitResultString(scheme=None, authority=None, path=':', query=None, fragment=None)

According to RFC 3986, ":" belongs to

gen-delims  = ":" / "/" / "?" / "#" / "[" / "]" / "@"

and should therefore better be encoded if used in path components. However, uritools tries to follow the robustness principle of be strict in what you server, but be liberal in what you accept, and therefore a single ":" is accepted as a path.

@Silvanoc
Copy link
Author

and should therefore better be encoded if used in path components

What I read in the RFC 3986 (end of the page) is "the conflicting data MUST be percent-encoded before the URI is formed" (formatting is mine). So I would say that : is not valid URIs according RFC 3986, since it doesn't delimit any data (and would therefore be part of the data).

uritools tries to follow the robustness principle of be strict in what you server, but be liberal in what you accept, and therefore a single ":" is accepted as a path.

IMHO having a strict flag or similar would be helpfull for this purpose. That way uritools could remain by default "liberal" on what it accepts, but get "strict" on demand.

Just to give you some context information. I'm not using uritools mostly due to this behaviour, which would force the project I'm collaborating on to make one of the tests less strict.
We have taken a different approach, so whatever feedback I provide you here is just part of my "sharing is caring" mindset.
I you don't want it, simply close this issue 🙂

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

No branches or pull requests

2 participants