From 822b99f09735e2b5b8e723acfbd16ed8e9e12615 Mon Sep 17 00:00:00 2001 From: Iwan Aucamp Date: Mon, 14 Sep 2020 20:57:10 +0200 Subject: [PATCH] Treat invalid IRIs as errors in conversion to RDF Currently invalid (i.e. non absolute) IRIs are ignored and tripples containing non absolute IRIs are omitted from the RDF resulting from `to_rdf`. This patch changes this behaviour so that non absolute IRIs result in exceptions instead. --- lib/pyld/jsonld.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py index 49d6212..54fe4b4 100644 --- a/lib/pyld/jsonld.py +++ b/lib/pyld/jsonld.py @@ -3545,10 +3545,16 @@ def _graph_to_rdf(self, graph, issuer, options): continue for item in items: - # skip relative IRI subjects and predicates + # All IDs should be absolute at this point in time if not (_is_absolute_iri(id_) and _is_absolute_iri(property)): - continue + raise JsonLdError( + 'JSON-LD graph conversion error; ' + 'invalid IRI for property or ID, ' + 'IRIs must be absolute', + 'jsonld.RdfError', + {'@id': id_, 'property': property}, + code='invalid IRI') # RDF subject subject = {}