[Python-modules-commits] [python-pyld] 113/276: Check invalid keyword aliasing via @id.

Wolfgang Borgert debacle at moszumanska.debian.org
Wed Oct 8 23:47:59 UTC 2014


This is an automated email from the git hooks/post-receive script.

debacle pushed a commit to branch master
in repository python-pyld.

commit 09fbcc14b57696c2cf9a407227c39951dcc06d5b
Author: Dave Longley <dlongley at digitalbazaar.com>
Date:   Mon Apr 15 11:09:12 2013 -0400

    Check invalid keyword aliasing via @id.
---
 lib/pyld/jsonld.py | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/lib/pyld/jsonld.py b/lib/pyld/jsonld.py
index fdf3893..d8a2bd1 100644
--- a/lib/pyld/jsonld.py
+++ b/lib/pyld/jsonld.py
@@ -3380,24 +3380,9 @@ class JsonLdProcessor:
             defined[term] = True
             return
 
+        # convert short-hand value to object w/@id
         if _is_string(value):
-            # expand value to a full IRI
-            id_ = self._expand_iri(
-                active_ctx, value, vocab=True, base=True,
-                local_ctx=local_ctx, defined=defined)
-
-            if _is_keyword(value):
-                # disallow aliasing @context and @preserve
-                if value == '@context' or value == '@preserve':
-                    raise JsonLdError(
-                        'Invalid JSON-LD syntax; @context and @preserve '
-                        'cannot be aliased.', 'jsonld.SyntaxError',
-                        {'context': local_ctx})
-
-            # define term to expanded IRI/keyword
-            active_ctx['mappings'][term] = {'@id': id_, 'reverse': False}
-            defined[term] = True
-            return
+            value = {'@id': value}
 
         if not _is_object(value):
             raise JsonLdError(
@@ -3509,6 +3494,14 @@ class JsonLdProcessor:
                 language = language.lower()
             mapping['@language'] = language
 
+        # disallow aliasing @context and @preserve
+        id_ = mapping['@id']
+        if id_ == '@context' or id_ == '@preserve':
+            raise JsonLdError(
+                'Invalid JSON-LD syntax; @context and @preserve '
+                'cannot be aliased.', 'jsonld.SyntaxError',
+                {'context': local_ctx})
+
         # define term mapping
         active_ctx['mappings'][term] = mapping
         defined[term] = True

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/python-pyld.git



More information about the Python-modules-commits mailing list