Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discourage using "out-of-container" relative URLs #1939

Merged
merged 15 commits into from
Dec 7, 2021
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions epub33/core/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5984,24 +5984,13 @@ <h4>URLs in the OCF Abstract Container</h4>

</div>

<p> In the <a>OCF Abstract Container</a>, when a file uses a URL string to reference another file in
the container, the string MUST be a
<a data-cite="url#path-relative-scheme-less-url-string">path-relative-scheme-less-URL string</a>,
<p>
A string is a <dfn id="dfn-valid-relative-container-url-string">valid-relative-container-URL-string</dfn> if it is
iherman marked this conversation as resolved.
Show resolved Hide resolved
a <a data-cite="url#path-relative-scheme-less-url-string">path-relative-scheme-less-URL string</a>,
optionally followed by <code>U+0023 (#)</code> and a
<a data-cite="url#url-fragment-string">URL-fragment string</a>.
<a data-cite="url#url-fragment-string">URL-fragment string</a>, and if the following steps return <var>true</var>:
</p>

<p class="note">
The properties of the <a>container root URL</a> are such that whatever the amount
of <a data-cite="url/#double-dot-path-segment">double-dot path segments</a> in a URL string (for
example, <code>../../../secret</code>), it is parsed to a <a>content URL</a> (and not "leak"
outside the container). This avoids potential run-time security issues.
Furthermore, the additional constraint and <a href="#algo-out-of-container">algorithm</a> below
ensure that such potentially problematic URLs can also be detected when checking the EPUB Document.
</p>

<p>To validate a URL string <var>url</var> found in the <a>OCF Abstract Container</a>, the following steps SHOULD return <var>true</var>:</p>

<ol class="algorithm" id="algo-out-of-container">
<li>
Set the <a>container root URL</a> to <code>https://a.example.org/A/</code>.
iherman marked this conversation as resolved.
Show resolved Hide resolved
Expand Down Expand Up @@ -6086,11 +6075,28 @@ <h4>URLs in the OCF Abstract Container</h4>
<li>Return <var>false</var>.</li>
</ol>

<p class="note">
For better interoperability with non-conforming or legacy Reading Systems and toolchains,
EPUB Creators should not use more <a data-cite="url/#double-dot-path-segment">double-dot path segments</a>
than needed to reach the target container file.
</p>
<p>
In the <a>OCF Abstract Container</a>, any URL string MUST be an <a data-cite="url#absolute-url-with-fragment-string">absolute-URL-with-fragment-string</a> or a <a>valid-relative-container-URL-string</a>.
iherman marked this conversation as resolved.
Show resolved Hide resolved
</p>

<div class="note">
<p>
The properties of the <a>container root URL</a> are such that whatever the amount
of <a data-cite="url#double-dot-path-segment">double-dot path segments</a> in a URL string (for
example, <code>../../../secret</code>), it is parsed to a <a>content URL</a> (and not "leak"
outside the container). This avoids potential run-time security issues.
The additional constraint on <a>valid-relative-container-URL-strings</a>
ensures that such potentially problematic URLs can also be detected when checking the EPUB Publication.
</p>


<p>
For better interoperability with non-conforming or legacy Reading Systems and toolchains,
EPUB Creators should not use more <a data-cite="url#double-dot-path-segment">double-dot path segments</a>
than needed to reach the target container file.
</p>

</div>

<aside class="example" title="Referencing a file in the same directory">
<p>In this example, the file <code>image1.jpg</code> is in the same directory as the <a>XHTML
Expand Down Expand Up @@ -6120,7 +6126,7 @@ <h4>URLs in the OCF Abstract Container</h4>
</pre>

<p>
A URL `../../../../EPUB/secret.xhtml` appearing in `content.xhtml` would be parsed by a Reading System into a <a>content URL</a> with a path `EPUB/secret.xhtml`, following the constraints on the <a>container root URL</a>. However, as the URL could be perceived as one of a resource outside the container, and create interoperability issues, it would be reported as a warning by a checker tool.
A URL `../../../../EPUB/secret.xhtml` appearing in `content.xhtml` would be parsed by a Reading System into a <a>content URL</a> with a path `EPUB/secret.xhtml`, following the constraints on the <a>container root URL</a>. However, as the URL could be perceived as one of a resource outside the container, and create interoperability issues; it would be reported as an error by a checker tool.
</p>
</aside>
</section>
Expand Down Expand Up @@ -10555,6 +10561,9 @@ <h2>Change Log</h2>
>Working Group's issue tracker</a>.</p>

<ul>

<li>03-Dec-2021: Remove the element-based restrictions on remote resources. See <a
href="https://github.com/w3c/epub-specs/issues/1913">issue 1913</a>.</li>
<li>26-Nov-2021: A requirement and an algorithm to detect out-of-container URLs has been added to the
specification. See <a href="https://github.com/w3c/epub-specs/issues/1912">issue 1912</a>
</li>
Expand Down