Skip to content

Commit 94b8c5f

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 3c6b442 commit 94b8c5f

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
@@ -3520,7 +3520,7 @@ <h3>Algorithm</h3>
35203520
<a data-lt="active context">active context's</a> <a>vocabulary mapping</a>.
35213521
Try to create a <a>compact IRI</a>, starting by initializing
35223522
<var>compact IRI</var> to <code>null</code>. This variable will be used to
3523-
tore the created <a>compact IRI</a>, if any.</li>
3523+
store the created <a>compact IRI</a>, if any.</li>
35243524
<li>For each key <a>term</a> and value <a>term definition</a> in
35253525
the <var>active context</var>:
35263526
<ol>
@@ -3547,6 +3547,12 @@ <h3>Algorithm</h3>
35473547
</ol>
35483548
</li>
35493549
<li>If <var>compact IRI</var> is not <code>null</code>, return <var>compact IRI</var>.</li>
3550+
<li class="changed">To ensure that the <a>absolute IRI</a> <var>var</var> is
3551+
not confused with a <a>compact IRI</a>,
3552+
if the <a data-cite="RFC3986#section-3.1">IRI scheme</a> of <var>var</var>
3553+
matches any term in <a>active context</a>,
3554+
an <a data-link-for="JsonLdErrorCode">iri confused with prefix</a> error has been detected,
3555+
and processing is aborted.</li>
35503556
<li>If <var>vocab</var> is <code>false</code>,
35513557
transform <var>var</var> to a <a>relative IRI</a> using
35523558
the <span class="changed"><a>base IRI</a> from <var>active context</var>, if it exists</span>.</li>
@@ -5921,6 +5927,7 @@ <h4>JsonLdErrorCode</h4>
59215927
"invalid value object",
59225928
"invalid value object value",
59235929
"invalid vocab mapping",
5930+
"iri confused with prefix",
59245931
"keyword redefinition",
59255932
"loading document failed",
59265933
"loading remote context failed",
@@ -6028,6 +6035,9 @@ <h4>JsonLdErrorCode</h4>
60286035
<dt><dfn>invalid vocab mapping</dfn></dt>
60296036
<dd>An invalid <a>vocabulary mapping</a> has been detected,
60306037
i.e., it is neither an <a>IRI</a> nor <code>null</code>.</dd>
6038+
<dt class="changed">iri confused with prefix</dt>
6039+
<dd>When compacting an <a>absolute IRI</a> would result in an <a>absolute IRI</a>
6040+
with an <a data-cite="RFC3986#section-3.1">IRI scheme</a> could be confused with a term.</dd>
60316041
<dt><dfn>keyword redefinition</dfn></dt>
60326042
<dd>A <a>keyword</a> redefinition has been detected.</dd>
60336043
<dt><dfn>loading document failed</dfn></dt>
@@ -6194,6 +6204,9 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
61946204
This allows a mechanism for documenting the content of a context using HTML.</li>
61956205
<li>Consolidate <a>RemoteDocument</a> processing into the <a>LoadDocumentCallback</a>
61966206
including variations on HTML processing.</li>
6207+
<li>The <a href="#iri-compaction">IRI compaction algorithm</a> may generate an error if the result is an
6208+
<a>absolute IRI</a> where the scheme part could be confused with a term in the
6209+
<a>active context</a>.</li>
61976210
</ul>
61986211
</section>
61996212

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)