diff --git a/rdflib/plugins/parsers/ntriples.py b/rdflib/plugins/parsers/ntriples.py index 99b966b1b..67dbe9d7b 100644 --- a/rdflib/plugins/parsers/ntriples.py +++ b/rdflib/plugins/parsers/ntriples.py @@ -28,7 +28,7 @@ __all__ = ['unquote', 'uriquote', 'Sink', 'NTriplesParser'] -uriref = r'<([^:]+:[^\s"<>]+)>' +uriref = r'<([^:]+:[^\s"<>]*)>' literal = r'"([^"\\]*(?:\\.[^"\\]*)*)"' litinfo = r'(?:@([a-zA-Z]+(?:-[a-zA-Z0-9]+)*)|\^\^' + uriref + r')?' diff --git a/test/test_issue920.py b/test/test_issue920.py new file mode 100644 index 000000000..eb12edc49 --- /dev/null +++ b/test/test_issue920.py @@ -0,0 +1,36 @@ +""" +Issue 920 - NTriples fails to parse URIs with only a scheme + +from rdflib import Graph +g=Graph() +g.parse(data=' .', format='nt') # nquads also fails + +N3, by contrast, succeeds: + +g.parse(data=' .', format='n3') +""" +from rdflib import Graph +import unittest + + +class TestIssue920(unittest.TestCase): + + def test_issue_920(self): + g = Graph() + # NT tests + g.parse(data=' .', format='nt') + g.parse(data=' .', format='nt') + g.parse(data=' .', format='nt') + + # related parser tests + g.parse(data=' .', format='turtle') + g.parse(data=' .', format='turtle') + g.parse(data=' .', format='turtle') + + g.parse(data=' .', format='n3') + g.parse(data=' .', format='n3') + g.parse(data=' .', format='n3') + + +if __name__ == "__main__": + unittest.main()