Skip to content

Commit 3153e5e

Browse files
authored
Make get, decode, and split handle edge cases correctly
Correct handling of the empty string input and input with a trailing comma. Fixes #1768.
1 parent 4cb3cf2 commit 3153e5e

File tree

1 file changed

+29
-25
lines changed

1 file changed

+29
-25
lines changed

fetch.bs

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,19 @@ A: nosniff
698698
B: sniff
699699
A:
700700
</code></pre>
701+
<tr>
702+
<td>
703+
<pre><code class=lang-http>
704+
A:
705+
B: sniff
706+
</code></pre>
707+
<td>« "" »
708+
<tr>
709+
<td>
710+
<pre><code class=lang-http>
711+
B: sniff
712+
</code></pre>
713+
<td>null
701714
<tr>
702715
<td>
703716
<pre><code class=lang-http>A: text/html;", x/x</code></pre>
@@ -763,12 +776,12 @@ a <a for=/>header value</a> <var>value</var>, run these steps. They return a <a
763776
<li><p>Let <var>position</var> be a <a for=string>position variable</a> for <var>input</var>,
764777
initially pointing at the start of <var>input</var>.
765778

766-
<li><p>Let <var>values</var> be a <a for=/>list</a> of <a for=/>strings</a>, initially empty.
779+
<li><p>Let <var>values</var> be a <a for=/>list</a> of <a for=/>strings</a>, initially « ».
767780

768781
<li><p>Let <var>temporaryValue</var> be the empty string.
769782

770783
<li>
771-
<p>While <var>position</var> is not past the end of <var>input</var>:
784+
<p>While true:
772785

773786
<ol>
774787
<li>
@@ -778,40 +791,30 @@ a <a for=/>header value</a> <var>value</var>, run these steps. They return a <a
778791
<p class=note>The result might be the empty string.
779792

780793
<li>
781-
<p>If <var>position</var> is not past the end of <var>input</var>, then:
794+
<p>If <var>position</var> is not past the end of <var>input</var> and the
795+
<a for=/>code point</a> at <var>position</var> within <var>input</var> is U+0022 ("):
782796

783797
<ol>
784-
<li>
785-
<p>If the <a for=/>code point</a> at <var>position</var> within <var>input</var> is
786-
U+0022 ("), then:
787-
788-
<ol>
789-
<li><p>Append the result of <a>collecting an HTTP quoted string</a> from <var>input</var>,
790-
given <var>position</var>, to <var>temporaryValue</var>.
798+
<li><p>Append the result of <a>collecting an HTTP quoted string</a> from <var>input</var>,
799+
given <var>position</var>, to <var>temporaryValue</var>.
791800

792-
<li>If <var>position</var> is not past the end of <var>input</var>, then
793-
<a for=iteration>continue</a>.
794-
</ol>
795-
796-
<li>
797-
<p>Otherwise:
798-
799-
<ol>
800-
<li><p>Assert: the <a for=/>code point</a> at <var>position</var> within <var>input</var> is
801-
U+002C (,).
802-
803-
<li><p>Advance <var>position</var> by 1.
804-
</ol>
801+
<li>If <var>position</var> is not past the end of <var>input</var>, then
802+
<a for=iteration>continue</a>.
805803
</ol>
806804

807805
<li><p>Remove all <a>HTTP tab or space</a> from the start and end of <var>temporaryValue</var>.
808806

809807
<li><p><a for=list>Append</a> <var>temporaryValue</var> to <var>values</var>.
810808

811809
<li><p>Set <var>temporaryValue</var> to the empty string.
812-
</ol>
813810

814-
<li><p>Return <var>values</var>.
811+
<li><p>If <var>position</var> is past the end of <var>input</var>, then return <var>values</var>.
812+
813+
<li><p><a for=/>Assert</a>: the <a for=/>code point</a> at <var>position</var> within
814+
<var>input</var> is U+002C (,).
815+
816+
<li><p>Advance <var>position</var> by 1.
817+
</ol>
815818
</ol>
816819

817820
<p class=note>Except for blessed call sites, the algorithm directly above is not to be invoked
@@ -9040,6 +9043,7 @@ Brad Porter,
90409043
Bryan Smith,
90419044
Caitlin Potter,
90429045
Cameron McCormack,
9046+
Carlo Cannas,
90439047
白丞祐 (Cheng-You Bai)<!-- CYBAI; GitHub -->,
90449048
Chirag S Kumar<!-- fictionistique; GitHub -->,
90459049
Chris Needham,

0 commit comments

Comments
 (0)