validate URIs somewhere · Issue #266 · RDFLib/rdflib (original) (raw)

Currently you can pass any old nonsense to URIRef constructor, and get very broken serializations out of RDFLib:

In [13]: g=rdflib.Graph()

In [14]: g.add((rdflib.URIRef("LOL I'm not really a URI at all! <> <> :)"), rdflib.RDF.type, rdflib.RDFS.Class))

In [15]: print g.serialize(format='n3') @prefix rdfs: http://www.w3.org/2000/01/rdf-schema# .

<LOL I'm not really a URI at all! <> <> :)> a rdfs:Class .

We should probably validate URIs at some point.

Graham points to https://pypi.python.org/pypi/rfc3987

I am slightly worried about performance, maybe a test is in order.

This issue was distilled out of #263