diff options
author | Natanael Arndt <arndtn@gmail.com> | 2020-03-16 17:29:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-16 17:29:12 +0100 |
commit | 107ffb6467f813980dcccd1f652ccde6b97d8d32 (patch) | |
tree | fa7579f9c54b51a2aabfb9feca71804667f0271b | |
parent | cbe9c9d0696b73783260aa4937298bca19352de6 (diff) | |
parent | 074adcc5f97c27e4fd3ec62e21903c594e79aa06 (diff) | |
download | rdflib-107ffb6467f813980dcccd1f652ccde6b97d8d32.tar.gz |
Merge pull request #974 from nicholascar/Issue-920-redux
Issue 920 fixes as per Issue desc + test
-rw-r--r-- | rdflib/plugins/parsers/ntriples.py | 2 | ||||
-rw-r--r-- | test/test_issue920.py | 36 |
2 files changed, 37 insertions, 1 deletions
diff --git a/rdflib/plugins/parsers/ntriples.py b/rdflib/plugins/parsers/ntriples.py index 99b966b1..67dbe9d7 100644 --- a/rdflib/plugins/parsers/ntriples.py +++ b/rdflib/plugins/parsers/ntriples.py @@ -28,7 +28,7 @@ from six import unichr __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 00000000..eb12edc4 --- /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='<a:> <b:> <c:> .', format='nt') # nquads also fails + +N3, by contrast, succeeds: + +g.parse(data='<a:> <b:> <c:> .', format='n3') +""" +from rdflib import Graph +import unittest + + +class TestIssue920(unittest.TestCase): + + def test_issue_920(self): + g = Graph() + # NT tests + g.parse(data='<a:> <b:> <c:> .', format='nt') + g.parse(data='<http://a> <http://b> <http://c> .', format='nt') + g.parse(data='<https://a> <http://> <http://c> .', format='nt') + + # related parser tests + g.parse(data='<a:> <b:> <c:> .', format='turtle') + g.parse(data='<http://a> <http://b> <http://c> .', format='turtle') + g.parse(data='<https://a> <http://> <http://c> .', format='turtle') + + g.parse(data='<a:> <b:> <c:> .', format='n3') + g.parse(data='<http://a> <http://b> <http://c> .', format='n3') + g.parse(data='<https://a> <http://> <http://c> .', format='n3') + + +if __name__ == "__main__": + unittest.main() |