Skip to content

Commit

Permalink
Merge pull request #974 from nicholascar/Issue-920-redux
Browse files Browse the repository at this point in the history
Issue 920 fixes as per Issue desc + test
  • Loading branch information
white-gecko authored Mar 16, 2020
2 parents cbe9c9d + 074adcc commit 107ffb6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdflib/plugins/parsers/ntriples.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')?'

Expand Down
36 changes: 36 additions & 0 deletions test/test_issue920.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 107ffb6

Please sign in to comment.