Skip to content
Permalink
Browse files

File state did not correctly deal with lack of base URL

  • Loading branch information...
annevk committed Feb 7, 2017
1 parent b087fe2 commit 698f3e8f1d7de6d84c78ac81209fd780aca5ab7e
Showing with 51 additions and 62 deletions.
  1. +51 −62 url.bs
113 url.bs
@@ -1742,81 +1742,70 @@ string <var>input</var>, optionally with a <a>base URL</a> <var>base</var>, opti


<dt><dfn>file state</dfn> <dt><dfn>file state</dfn>
<dd> <dd>
<p>Set <var>url</var>'s <a for=url>scheme</a> to "<code>file</code>", <ol>
and then, switching on <a>c</a>: <li><p>Set <var>url</var>'s <a for=url>scheme</a> to "<code>file</code>".


<dl class=switch> <li>
<dt><a>EOF code point</a> <p>If <a>c</a> is "<code>/</code>" or "<code>\</code>", then:
<dd><p>If <var>base</var> is non-null and <var>base</var>'s
<a for=url>scheme</a> is "<code>file</code>", set
<var>url</var>'s <a for=url>host</a> to
<var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>path</a> to
<var>base</var>'s <a for=url>path</a>, and
<var>url</var>'s <a for=url>query</a> to
<var>base</var>'s <a for=url>query</a>.


<dt>"<code>/</code>"
<dt>"<code>\</code>"
<dd>
<ol> <ol>
<li><p>If <a>c</a> is "<code>\</code>", <a>syntax violation</a>. <li><p>If <a>c</a> is "<code>\</code>", <a>syntax violation</a>.


<li><p>Set <var>state</var> to <a>file slash state</a>. <li><p>Set <var>state</var> to <a>file slash state</a>.
</ol> </ol>


<dt>"<code>?</code>" <li>
<dd><p>If <var>base</var> is non-null and <var>base</var>'s <p>Otherwise, if <var>base</var> is non-null and <var>base</var>'s <a for=url>scheme</a> is
<a for=url>scheme</a> is "<code>file</code>", set "<code>file</code>", switch on <a>c</a>:
<var>url</var>'s <a for=url>host</a> to
<var>base</var>'s <a for=url>host</a>, <dl class=switch>
<var>url</var>'s <a for=url>path</a> to <dt><a>EOF code point</a>
<var>base</var>'s <a for=url>path</a>, <dd><p>Set <var>url</var>'s <a for=url>host</a> to <var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>query</a> to the empty string, <var>url</var>'s <a for=url>path</a> to <var>base</var>'s <a for=url>path</a>, and
and <var>state</var> to <a>query state</a>. <var>url</var>'s <a for=url>query</a> to <var>base</var>'s <a for=url>query</a>.

<dt>"<code>?</code>"
<dd><p>Set <var>url</var>'s <a for=url>host</a> to <var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>path</a> to <var>base</var>'s <a for=url>path</a>,
<var>url</var>'s <a for=url>query</a> to the empty string, and <var>state</var> to
<a>query state</a>.

<dt>"<code>#</code>"
<dd><p>Set <var>url</var>'s <a for=url>host</a> to <var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>path</a> to <var>base</var>'s <a for=url>path</a>,
<var>url</var>'s <a for=url>query</a> to <var>base</var>'s <a for=url>query</a>,
<var>url</var>'s <a for=url>fragment</a> to the empty string, and <var>state</var> to
<a>fragment state</a>.

<dt>Otherwise
<dd>
<ol>
<li>
<p>If at least one of the following is true


<dt>"<code>#</code>" <ul class=brief>
<dd><p>If <var>base</var> is non-null and <var>base</var>'s <li><p><a>c</a> and the first code point of <a>remaining</a> are not a
<a for=url>scheme</a> is "<code>file</code>", set <a>Windows drive letter</a>
<var>url</var>'s <a for=url>host</a> to <li><p><a>remaining</a> consists of one code point
<var>base</var>'s <a for=url>host</a>, <li><p><a>remaining</a>'s second code point is <em>not</em> "<code>/</code>",
<var>url</var>'s <a for=url>path</a> to "<code>\</code>", "<code>?</code>", or "<code>#</code>"
<var>base</var>'s <a for=url>path</a>, </ul>
<var>url</var>'s <a for=url>query</a> to
<var>base</var>'s <a for=url>query</a>,
<var>url</var>'s <a for=url>fragment</a> to the empty string,
and <var>state</var> to <a>fragment state</a>.


<dt>Otherwise <p>then set <var>url</var>'s <a for=url>host</a> to <var>base</var>'s <a for=url>host</a>,
<dd> <var>url</var>'s <a for=url>path</a> to <var>base</var>'s <a for=url>path</a>, and then
<ol> <a>shorten</a> <var>url</var>'s <a for=url>path</a>.
<li>
<p>If <var>base</var> is non-null, <var>base</var>'s <a for=url>scheme</a>
is "<code>file</code>", and at least one of the following is true

<ul class=brief>
<li><p><a>c</a> and the first code point of <a>remaining</a> are not a
<a>Windows drive letter</a>
<li><p><a>remaining</a> consists of one code point
<li><a>remaining</a>'s second code point is <em>not</em> "<code>/</code>",
"<code>\</code>", "<code>?</code>", or "<code>#</code>"
</ul>

<p>then set <var>url</var>'s <a for=url>host</a> to
<var>base</var>'s <a for=url>host</a>,
<var>url</var>'s <a for=url>path</a> to
<var>base</var>'s <a for=url>path</a>, and then <a>shorten</a>
<var>url</var>'s <a for=url>path</a>.


<p class=note>This is a (platform-independent) Windows drive letter quirk. <p class=note>This is a (platform-independent) Windows drive letter quirk.


<li><p>Otherwise, if <var>base</var> is non-null and <var>base</var>'s <li><p>Otherwise, <a>syntax violation</a>.
<a for=url>scheme</a> is "<code>file</code>", <a>syntax violation</a>.


<li><p>Set <var>state</var> to <a>path state</a>, and decrease <var>pointer</var> <li><p>Set <var>state</var> to <a>path state</a>, and decrease <var>pointer</var> by one.
by one. </ol>
</ol> </dl>
</dl>
<li><p>Otherwise, set <var>state</var> to <a>path state</a>, and decrease <var>pointer</var> by
one.
</ol>


<dt><dfn>file slash state</dfn> <dt><dfn>file slash state</dfn>
<dd> <dd>

0 comments on commit 698f3e8

Please sign in to comment.
You can’t perform that action at this time.