Skip to content

Commit 1385b12

Browse files
committed
Detect an attempt to compact an IRI which results in an absolute IRI where the scheme matches a term in the active context.
Fixes #104.
1 parent 1466f97 commit 1385b12

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

index.html

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ <h3>Algorithm</h3>
35163516
<a data-lt="active context">active context's</a> <a>vocabulary mapping</a>.
35173517
Try to create a <a>compact IRI</a>, starting by initializing
35183518
<var>compact IRI</var> to <code>null</code>. This variable will be used to
3519-
tore the created <a>compact IRI</a>, if any.</li>
3519+
store the created <a>compact IRI</a>, if any.</li>
35203520
<li>For each key <a>term</a> and value <a>term definition</a> in
35213521
the <var>active context</var>:
35223522
<ol>
@@ -3543,6 +3543,12 @@ <h3>Algorithm</h3>
35433543
</ol>
35443544
</li>
35453545
<li>If <var>compact IRI</var> is not <code>null</code>, return <var>compact IRI</var>.</li>
3546+
<li class="changed">To ensure that the <a>absolute IRI</a> <var>var</var> is
3547+
not confused with a <a>compact IRI</a>,
3548+
if the <a data-cite="RFC3986#section-3.1">IRI scheme</a> of <var>var</var>
3549+
matches any term in <a>active context</a>,
3550+
an <a data-link-for="JsonLdErrorCode">iri confused with prefix</a> error has been detected,
3551+
and processing is aborted.</li>
35463552
<li>If <var>vocab</var> is <code>false</code>,
35473553
transform <var>var</var> to a <a>relative IRI</a> using
35483554
the <span class="changed"><a>base IRI</a> from <var>active context</var>, if it exists</span>.</li>
@@ -5917,6 +5923,7 @@ <h4>JsonLdErrorCode</h4>
59175923
"invalid value object",
59185924
"invalid value object value",
59195925
"invalid vocab mapping",
5926+
"iri confused with prefix",
59205927
"keyword redefinition",
59215928
"loading document failed",
59225929
"loading remote context failed",
@@ -6024,6 +6031,9 @@ <h4>JsonLdErrorCode</h4>
60246031
<dt><dfn>invalid vocab mapping</dfn></dt>
60256032
<dd>An invalid <a>vocabulary mapping</a> has been detected,
60266033
i.e., it is neither an <a>IRI</a> nor <code>null</code>.</dd>
6034+
<dt class="changed">iri confused with prefix</dt>
6035+
<dd>When compacting an <a>absolute IRI</a> would result in an <a>absolute IRI</a>
6036+
with an <a data-cite="RFC3986#section-3.1">IRI scheme</a> could be confused with a term.</dd>
60276037
<dt><dfn>keyword redefinition</dfn></dt>
60286038
<dd>A <a>keyword</a> redefinition has been detected.</dd>
60296039
<dt><dfn>loading document failed</dfn></dt>
@@ -6190,6 +6200,9 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
61906200
This allows a mechanism for documenting the content of a context using HTML.</li>
61916201
<li>Consolidate <a>RemoteDocument</a> processing into the <a>LoadDocumentCallback</a>
61926202
including variations on HTML processing.</li>
6203+
<li>The <a href="#iri-compaction">IRI compaction algorithm</a> may generate an error if the result is an
6204+
<a>absolute IRI</a> where the scheme part could be confused with a term in the
6205+
<a>active context</a>.</li>
61936206
</ul>
61946207
</section>
61956208

tests/compact-manifest.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,6 +1148,15 @@
11481148
"input": "compact/e001-in.jsonld",
11491149
"context": "compact/e001-context.jsonld",
11501150
"expect": "compaction to list of lists"
1151+
}, {
1152+
"@id": "#te002",
1153+
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],
1154+
"name": "Absolute IRI confused with Compact IRI",
1155+
"purpose": "Verifies that IRI compaction detects when the result is an absolute IRI with a scheme matching a term.",
1156+
"option": {"specVersion": "json-ld-1.1"},
1157+
"input": "compact/e002-in.jsonld",
1158+
"context": "compact/e002-context.jsonld",
1159+
"expect": "IRI confused with prefix"
11511160
}, {
11521161
"@id": "#ten01",
11531162
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],

tests/compact/e002-context.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"tag": "http://example.org/ns/tag/"
4+
}
5+
}

tests/compact/e002-in.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"tag:champin.net,2019:prop": {"@value": "hello world"}
3+
}]

0 commit comments

Comments
 (0)