greater") >>> g = rdflib.Graph() >>> g.add((u, u, u)) >>> g.serialize(fo...">

n3 (turtle, nt) serializer fails to encode '>' character · Issue #263 · RDFLib/rdflib (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

@chrysn

Description

@chrysn

graphs containing urls containing the '>' are not escaped properly.

for example:

>>> u = rdflib.URIRef("http://foo/less<than>greater")
>>> g = rdflib.Graph()
>>> g.add((u, u, u))
>>> g.serialize(format='nt')
b'<http://foo/less<than>greater> <http://foo/less<than>greater> <http://foo/less<than>greater> .\n\n'

the best documentation i could strike up was [1](on turtle), where it explicitly says that a URI may only contain ucharacter, which may not contain an unescaped '>'. i don't know how precisely characters are to be escaped to be valid in n3/turtle/nt, but but return "<%s>" % self (from rdflib.term.URIRef's n3 method) most certainly isn't.

[1] http://www.w3.org/TeamSubmission/turtle/#relativeURI