Comments (6)
Also a problem when host is '['
from rfc3986.
Happy to accept a fix here
from rfc3986.
The question here is whether the validation should or should not be implicit when using uri_reference
. The truth is that it parses the URI and returns an invalid result by default:
In [1]: from rfc3986 import uri_reference
In [2]: uri_reference("B://]")
Out[2]: URIReference(scheme='B', authority=']', path=None, query=None, fragment=None)
But you can simply check the validity of the result by the is_valid()
method:
In [3]: _.is_valid()
Out[3]: False
If you want the validation to happen immediately during parsing, you can use ParseResult
:
In [4]: from rfc3986 import ParseResult
In [5]: ParseResult.from_string("B://]")
…
InvalidAuthority: The authority (]) is not valid.
So, because the lib is already able to say that the URL is invalid, it's more a design decision if the validation should happen by default.
from rfc3986.
Pretty sure uri_reference
was always intended to be non-validating so that the rest could be API compatible with urllib3 more or less.
Maybe we need to make that clearer in the docs
from rfc3986.
@kenballus could you please clarify which approach did you use?
from rfc3986.
My mistake; using ParseResult.from_string
fixes this. I should have read the docs more thoroughly.
Why is it that we have a non-validating parser? Some large projects (httpx) use this parser, and would probably be better off using ParseResult.from_string
.
from rfc3986.
Related Issues (20)
- ParseResult.fromString accepts ports that aren't preceded by a ':' character
- To encode or not encode - best practices for "uncommon" uri characters, including whitespaces (%20)? HOT 1
- 2.0.1 patch release? HOT 2
- any way to validate only relative path? HOT 1
- The remove_dot_segments() function returns a relative path for an absolute input path after removing dot-dot segments. HOT 1
- URLs ending in "\n" are stripped of the new-line before normalization
- Simple typo in the URIReference docstring in src/rfc3986/uri.py
- Newest release not are not shown on https://rfc3986.readthedocs.io HOT 2
- ccccccgcdkhvdkfdifgedbbhgrdkkbnnchvufulbtlhn HOT 1
- Empty (but present) authority component lost
- 1.5.0: pytest `DeprecationWarning` warnings HOT 1
- Resolving a relative URI Reference against a base with only an authority does not work HOT 2
- Resolution result is not consistent with RFC 3986 when the base has "rootless" path without authority
- The first path segment is unexpectedly interpreted as an authority after normalization
- URIMixin.resolve_with emits a warning
- PATH_EMPTY regex does not actually match empty path HOT 3
- ":" in relative path within relative reference HOT 1
- 2.0.1 patch release? HOT 1
- Parsing of fragments through ParseResult.fromString can be cut short by a newline character
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rfc3986.