aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/triple_store/sparql/sparql.py
diff options
context:
space:
mode:
authorMatthias Baumgartner <dev@igsor.net>2023-03-02 15:29:12 +0100
committerMatthias Baumgartner <dev@igsor.net>2023-03-02 15:29:12 +0100
commitb66ed641d5cbb4cb83f4a571223e4d65d80ed05c (patch)
treecf52e778f611e7520bd92b99df22b6bf69e552ec /bsfs/triple_store/sparql/sparql.py
parent2e07f33314c238e42bfadc5f39805f93ffbc622e (diff)
downloadbsfs-b66ed641d5cbb4cb83f4a571223e4d65d80ed05c.tar.gz
bsfs-b66ed641d5cbb4cb83f4a571223e4d65d80ed05c.tar.bz2
bsfs-b66ed641d5cbb4cb83f4a571223e4d65d80ed05c.zip
check non-serializable URIs in the sparql store
Diffstat (limited to 'bsfs/triple_store/sparql/sparql.py')
-rw-r--r--bsfs/triple_store/sparql/sparql.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/bsfs/triple_store/sparql/sparql.py b/bsfs/triple_store/sparql/sparql.py
index 5890bcc..bd98f46 100644
--- a/bsfs/triple_store/sparql/sparql.py
+++ b/bsfs/triple_store/sparql/sparql.py
@@ -284,6 +284,9 @@ class SparqlStore(base.TripleStoreBase):
raise errors.ConsistencyError(f'{node_type} is not defined in the schema')
# check and create guids
for guid in guids:
+ # check convert to rdflib.URIRef
+ if not rdflib.term._is_valid_uri(guid): # pylint: disable=protected-access
+ raise ValueError(guids)
subject = rdflib.URIRef(guid)
# check node existence
if (subject, rdflib.RDF.type, None) in self._graph:
@@ -324,6 +327,9 @@ class SparqlStore(base.TripleStoreBase):
# check guids
# FIXME: Fail or skip inexistent nodes?
guids = set(guids)
+ invalid = {guid for guid in guids if not rdflib.term._is_valid_uri(guid)} # pylint: disable=protected-access
+ if len(invalid) > 0:
+ raise ValueError(invalid)
inconsistent = {guid for guid in guids if not self._has_type(guid, node_type)}
if len(inconsistent) > 0:
raise errors.InstanceError(inconsistent)