diff options
author | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 16:40:00 +0100 |
---|---|---|
committer | Matthias Baumgartner <dev@igsor.net> | 2023-03-02 16:40:00 +0100 |
commit | 28a021483c13e974e00b6159f0653b0727df9d10 (patch) | |
tree | e5aa55337a5b2e5c5e34b7892a0cbe0997eb0da8 /bsfs/utils/uri.py | |
parent | b66ed641d5cbb4cb83f4a571223e4d65d80ed05c (diff) | |
download | bsfs-28a021483c13e974e00b6159f0653b0727df9d10.tar.gz bsfs-28a021483c13e974e00b6159f0653b0727df9d10.tar.bz2 bsfs-28a021483c13e974e00b6159f0653b0727df9d10.zip |
prohibit certain characters in URI and ensure URIs in bsfs.graph
Diffstat (limited to 'bsfs/utils/uri.py')
-rw-r--r-- | bsfs/utils/uri.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/bsfs/utils/uri.py b/bsfs/utils/uri.py index 0693017..5755a6e 100644 --- a/bsfs/utils/uri.py +++ b/bsfs/utils/uri.py @@ -4,6 +4,8 @@ import re import typing # constants +RX_CHARS = re.compile(r'[<>" {}|\\^]') + RX_URI = re.compile(r''' ^ (?:(?P<scheme>[^:/?#]+):)? # scheme, ://-delimited @@ -77,6 +79,9 @@ class URI(str): no claim about the validity of an URI! """ + # check characters + if RX_CHARS.search(query) is not None: + return False # check uri parts = RX_URI.match(query) if parts is not None: @@ -227,9 +232,6 @@ class URI(str): # overload formatting methods - def format(self, *args, **kwargs) -> 'URI': - return URI(super().format(*args, **kwargs)) - def __mod__(self, *args) -> 'URI': return URI(super().__mod__(*args)) |