Skip to content

Commit 01d031f

Browse files
committed
Make requirement for entity encoding non-normative, and update examples to not show automatic decoding.
1 parent 2d815c4 commit 01d031f

File tree

3 files changed

+32
-40
lines changed

3 files changed

+32
-40
lines changed

Gemfile.lock

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
GIT
22
remote: git://github.com/ruby-rdf/json-ld.git
3-
revision: 488d5e7737d401bb83a246248ad2f921c56938c4
3+
revision: a26c3205d006550f85162848a4a2bc3366b39970
44
branch: develop
55
specs:
66
json-ld (3.0.2)
7-
multi_json (~> 1.12)
8-
rdf (>= 2.2.8, < 4.0)
7+
multi_json (~> 1.13)
8+
rdf (~> 3.0, >= 3.0.4)
99

1010
GEM
1111
remote: https://rubygems.org/
@@ -16,7 +16,7 @@ GEM
1616
i18n
1717
builder (3.2.3)
1818
colorize (0.8.1)
19-
concurrent-ruby (1.0.5)
19+
concurrent-ruby (1.1.3)
2020
connection_pool (2.2.2)
2121
ebnf (1.1.3)
2222
rdf (~> 3.0)
@@ -29,9 +29,9 @@ GEM
2929
hamster (3.0.0)
3030
concurrent-ruby (~> 1.0)
3131
htmlentities (4.3.4)
32-
i18n (1.1.0)
32+
i18n (1.1.1)
3333
concurrent-ruby (~> 1.0)
34-
json-ld-preloaded (3.0.1)
34+
json-ld-preloaded (3.0.2)
3535
json-ld (~> 3.0)
3636
multi_json (~> 1.12)
3737
rdf (~> 3.0)
@@ -76,8 +76,8 @@ GEM
7676
nokogumbo (1.5.0)
7777
nokogiri
7878
public_suffix (3.0.3)
79-
rake (12.3.1)
80-
rdf (3.0.4)
79+
rake (12.3.2)
80+
rdf (3.0.7)
8181
hamster (~> 3.0)
8282
link_header (~> 0.0, >= 0.0.8)
8383
rdf-aggregate-repo (2.2.1)
@@ -126,7 +126,7 @@ GEM
126126
rdf-turtle (3.0.3)
127127
ebnf (~> 1.1)
128128
rdf (~> 3.0)
129-
rdf-vocab (3.0.3)
129+
rdf-vocab (3.0.4)
130130
rdf (~> 3.0)
131131
rdf-xsd (3.0.1)
132132
rdf (~> 3.0)
@@ -146,13 +146,13 @@ GEM
146146
rdf-xsd (~> 3.0)
147147
sparql-client (~> 3.0)
148148
sxp (~> 1.0)
149-
sparql-client (3.0.0)
149+
sparql-client (3.0.1)
150150
net-http-persistent (>= 2.9, < 4)
151151
rdf (~> 3.0)
152152
sxp (1.0.1)
153153
rdf (>= 2.2, < 4.0)
154154
temple (0.8.0)
155-
tilt (2.0.8)
155+
tilt (2.0.9)
156156

157157
PLATFORMS
158158
ruby
@@ -166,4 +166,4 @@ DEPENDENCIES
166166
rake
167167

168168
BUNDLED WITH
169-
1.16.4
169+
1.17.1

common/extract-examples.rb

+3-8
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ def save_example(examples:, element:, title:, example_number:, error:, warn:)
303303
# Perform example syntactic validation based on extension
304304
case ex[:ext]
305305
when 'json', 'jsonld', 'jsonldf'
306-
content = CGI.unescapeHTML(content)
307306
begin
308307
::JSON.parse(content)
309308
rescue JSON::ParserError => exception
@@ -327,9 +326,7 @@ def save_example(examples:, element:, title:, example_number:, error:, warn:)
327326
ex[:base] = html_base.to_s if html_base
328327

329328
script_content = doc.at_xpath(xpath)
330-
331-
# Remove (faked) XML comments and unescape sequences
332-
content = CGI.unescapeHTML(script_content.inner_html) if script_content
329+
content = script_content.inner_html if script_content
333330
rescue Nokogiri::XML::SyntaxError => exception
334331
errors << "Example #{ex[:number]} at line #{ex[:line]} parse error: #{exception.message}"
335332
$stdout.write "F".colorize(:red)
@@ -451,7 +448,7 @@ def save_example(examples:, element:, title:, example_number:, error:, warn:)
451448
$stdout.write "F".colorize(:red)
452449
next
453450
end
454-
StringIO.new(CGI.unescapeHTML(script_content.inner_html))
451+
StringIO.new(script_content.inner_html)
455452
elsif examples[ex[:result_for]][:ext] == 'html' && ex[:target]
456453
# Only use the targeted script
457454
doc = Nokogiri::HTML.parse(examples[ex[:result_for]][:content])
@@ -461,9 +458,7 @@ def save_example(examples:, element:, title:, example_number:, error:, warn:)
461458
$stdout.write "F".colorize(:red)
462459
next
463460
end
464-
StringIO.new(script_content
465-
.to_html
466-
.gsub(/&lt;/, '<'))
461+
StringIO.new(script_content.to_html)
467462
else
468463
StringIO.new(examples[ex[:result_for]][:content])
469464
end

index.html

+17-20
Original file line numberDiff line numberDiff line change
@@ -8820,27 +8820,24 @@ <h3>Graph Containers</h3>
88208820
<a data-cite="HTML52/infrastructure.html#dynamic-changes-to-base-urls">Dynamic changes to base URLs</a>.</p>
88218821
</section>
88228822

8823-
<section><h3>Restrictions for contents of JSON-LD <code>script</code> elements</h3>
8824-
<p class="issue atrisk">This section adds additional requirements for escaping
8825-
certain JSON values when embedding that JSON within HTML. This approach
8826-
is consequently subject to further discussion in the Working Group.</p>
8827-
8828-
<p>Depending on how the HTML document is served, certain strings may need
8829-
to be escaped to prevent disrupting the HTML parsing algorithm.</p>
8830-
8823+
<section class="informative"><h3>Restrictions for contents of JSON-LD <code>script</code> elements</h3>
88318824
<p>Due to the HTML <a data-cite="HTML52/semantics-scripting.html#restrictions-for-contents-of-script-elements">Restrictions for contents of <code>&lt;script&gt;</code> elements</a>
88328825
additional encoding restrictions are placed on JSON-LD data contained in
88338826
<a data-cite="HTML52/semantics-scripting.html#the-script-element">script elements</a>.</p>
8834-
<p>A JSON-LD script element MUST contain only valid JSON.
8835-
Any strings within the JSON content which contains text which can be confused with a <em>comment-open</em>, <em>script-open</em>,
8836-
<em>comment-close</em>, or <em>script-close</em> MUST be escaped using <a data-cite="HTML5/syntax.html#character-references">HTML Character references</a>, such as the following:</p>
8837-
<ul>
8838-
<li><code>&amp;amp;</code> → &amp; (<a href="/wiki/Ampersand" title="Ampersand">ampersand</a>, U+0026)</li>
8839-
<li><code>&amp;lt;</code> → &lt; (less-than sign, U+003C)</li>
8840-
<li><code>&amp;gt;</code> → &gt; (greater-than sign, U+003E)</li>
8841-
<li><code>&amp;quot;</code> → " (quotation mark, U+0022)</li>
8842-
<li><code>&amp;apos;</code> → ' (apostrophe, U+0027)</li>
8843-
</ul>
8827+
<p>Authors should avoid using character sequences in scripts embedded in HTML
8828+
which may be confused with a <em>comment-open</em>, <em>script-open</em>,
8829+
<em>comment-close</em>, or <em>script-close</em>.</p>
8830+
<div class="note">Such content should be escaped as indicated below, however
8831+
the content will remain escaped after processing through the
8832+
JSON-LD API [[JSON-LD11-API]].
8833+
<ul>
8834+
<li><code>&amp;amp;</code> → &amp; (<a href="/wiki/Ampersand" title="Ampersand">ampersand</a>, U+0026)</li>
8835+
<li><code>&amp;lt;</code> → &lt; (less-than sign, U+003C)</li>
8836+
<li><code>&amp;gt;</code> → &gt; (greater-than sign, U+003E)</li>
8837+
<li><code>&amp;quot;</code> → " (quotation mark, U+0022)</li>
8838+
<li><code>&amp;apos;</code> → ' (apostrophe, U+0027)</li>
8839+
</ul>
8840+
</div>
88448841

88458842
<aside class="example ds-selector-tabs"
88468843
title="Embedding JSON-LD containing HTML in HTML">
@@ -8870,7 +8867,7 @@ <h3>Graph Containers</h3>
88708867
"@type": ["http://schema.org/WebPageElement"],
88718868
"http://schema.org/name": [{"@value": "Encoding Issues"}],
88728869
"http://schema.org/description": [
8873-
{"@value": "Issues list such as unescaped </script> or - - >"}
8870+
{"@value": "Issues list such as unescaped &lt;/script&gt; or - -&gt;"}
88748871
]
88758872
}]
88768873
-->
@@ -8885,7 +8882,7 @@ <h3>Graph Containers</h3>
88858882
88868883
[ a schema:WebPageElement;
88878884
schema:name "Encoding Issues";
8888-
schema:description "Issues list such as unescaped </script> or - - >"
8885+
schema:description "Issues list such as unescaped &lt;/script&gt; or - -&gt;"
88898886
] .
88908887
-->
88918888
</pre>

0 commit comments

Comments
 (0)