Skip to content

Commit

Permalink
Merge pull request #1044 from aayush17002/patch-1
Browse files Browse the repository at this point in the history
Updating namespace.py to solve issue #801
  • Loading branch information
nicholascar committed Jul 30, 2020
2 parents e4fe0fd + 63a825f commit 7c7f763
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rdflib/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ def absolutize(self, uri, defrag=1):
NAME_START_CATEGORIES = ["Ll", "Lu", "Lo", "Lt", "Nl"]
SPLIT_START_CATEGORIES = NAME_START_CATEGORIES + ["Nd"]
NAME_CATEGORIES = NAME_START_CATEGORIES + ["Mc", "Me", "Mn", "Lm", "Nd"]
ALLOWED_NAME_CHARS = [u"\u00B7", u"\u0387", u"-", u".", u"_", u":"]
ALLOWED_NAME_CHARS = [u"\u00B7", u"\u0387", u"-", u".", u"_", u":", u"%"]


# http://www.w3.org/TR/REC-xml-names/#NT-NCName
Expand Down
19 changes: 19 additions & 0 deletions test/test_issue801.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Issue 801 - Problem with prefixes created for URIs containing %20
"""
from rdflib import Namespace, Graph, BNode, Literal
import unittest

class TestIssue801(unittest.TestCase):

def test_issue_801(self):
g = Graph()
example = Namespace('http://example.org/')
g.bind('', example)
node = BNode()
g.add((node, example['first%20name'], Literal('John')))
self.assertEqual(g.serialize(format="turtle").decode().split("\n")[-3],
'[] :first%20name "John" .')

if __name__ == "__main__":
unittest.main()

0 comments on commit 7c7f763

Please sign in to comment.