Skip to content

Commit 469b353

Browse files
authored
Fix "webauthn" autocomplete token parsing
Fix two bugs related to parsing the "webauthn" autocomplete token: * Prepend the second token to the IDL-exposed value when a "webauthn" token is found. * Reset the category after the "webauthn" token is found, otherwise parsing of "Contact" tokens is broken with a "webauthn" token. To do this, the steps that set a category and maximum number of tokens from a field are extracted into their own algorithm and called when starting parsing and after we find a "webauthn" tag. Fixes #8231.
1 parent c89b2c1 commit 469b353

File tree

1 file changed

+189
-160
lines changed

1 file changed

+189
-160
lines changed

source

Lines changed: 189 additions & 160 deletions
Original file line numberDiff line numberDiff line change
@@ -55684,19 +55684,196 @@ MIT Room 32-G524
5568455684
<li><p>Let <var>tokens</var> be the result of <span data-x="split a string on ASCII
5568555685
whitespace">splitting the attribute's value on ASCII whitespace</span>.</p></li>
5568655686

55687-
<li><p>If <var>tokens</var> is empty, then jump to the step labeled
55688-
<i>default</i>.</p></li>
55687+
<li><p>If <var>tokens</var> is empty, then jump to the step labeled <i>default</i>.</p></li>
5568955688

5569055689
<li><p>Let <var>index</var> be the index of the last token in <var>tokens</var>.</p></li>
5569155690

55691+
<li><p>Let <var>field</var> be the <var>index</var>th token in <var>tokens</var>.</p></li>
55692+
55693+
<li><p>Set the <var>category</var>, <var>maximum tokens</var> pair to the result of <span
55694+
data-x="determine a field's category">determining a field's category</span> given
55695+
<var>field</var>.</p></li>
55696+
55697+
<li><p>If <var>category</var> is null, then jump to the step labeled <i>default</i>.</p></li>
55698+
55699+
<li><p>If the number of tokens in <var>tokens</var> is greater than <var>maximum tokens</var>,
55700+
then jump to the step labeled <i>default</i>.</p></li>
55701+
55702+
<li><p>If <var>category</var> is Off or Automatic but the element's <code
55703+
data-x="attr-fe-autocomplete">autocomplete</code> attribute is wearing the <span>autofill anchor
55704+
mantle</span>, then jump to the step labeled <i>default</i>.</p></li>
55705+
55706+
<li><p>If <var>category</var> is Off, let the element's <span>autofill field name</span>
55707+
be the string "<code data-x="">off</code>", let its <span>autofill hint set</span> be empty, and
55708+
let its <span>IDL-exposed autofill value</span> be the string "<code data-x="">off</code>". Then,
55709+
return.</p>
55710+
55711+
<li><p>If <var>category</var> is Automatic, let the element's <span>autofill field
55712+
name</span> be the string "<code data-x="">on</code>", let its <span>autofill hint set</span> be
55713+
empty, and let its <span>IDL-exposed autofill value</span> be the string "<code
55714+
data-x="">on</code>". Then, return.</p>
55715+
55716+
<li><p>Let <var>scope tokens</var> be an empty list.</p></li>
55717+
55718+
<li><p>Let <var>hint tokens</var> be an empty set.</p></li>
55719+
55720+
<li><p>Let <var>credential type</var> be null.</p></li>
55721+
55722+
<li><p>Let <var>IDL value</var> have the same value as <var>field</var>.</p></li>
55723+
55724+
<li>
55725+
<p>If <var>category</var> is Credential and the <var>index</var>th token in <var>tokens</var> is
55726+
an <span>ASCII case-insensitive</span> match for "<code
55727+
data-x="attr-fe-autocomplete-webauthn">webauthn</code>", then run the substeps that follow:</p>
55728+
<ol>
55729+
<li><p>Set <var>credential type</var> to "<code data-x="">webauthn</code>".</p></li>
55730+
55731+
<li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
55732+
then skip to the step labeled <i>done</i>.</p></li>
55733+
55734+
<li><p>Decrement <var>index</var> by one.</p></li>
55735+
55736+
<li><p>Set the <var>category</var>, <var>maximum tokens</var> pair to the result of <span
55737+
data-x="determine a field's category">determining a field's category</span> given
55738+
the <var>index</var>th token in <var>tokens</var>.</p></li>
55739+
55740+
<li><p>If <var>category</var> is not Normal and <var>category</var> is not Contact, then jump to
55741+
the step labeled <i>default</i>.</p></li>
55742+
55743+
<li><p>If <var>index</var> is greater than <var>maximum tokens</var> minus one (i.e. if the
55744+
number of remaining tokens is greater than <var>maximum tokens</var>), then jump to the step
55745+
labeled <i>default</i>.</p></li>
55746+
55747+
<li><p>Set <var>IDL value</var> to the concatenation of the <var>index</var>th token in
55748+
<var>tokens</var>, a U+0020 SPACE character, and the previous value of <var>IDL
55749+
value</var>.</p></li>
55750+
</ol>
55751+
</li>
55752+
55753+
<li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
55754+
then skip to the step labeled <i>done</i>.</p></li>
55755+
55756+
<li><p>Decrement <var>index</var> by one.</p></li>
55757+
55758+
<li>
55759+
<p>If <var>category</var> is Contact and the <var>index</var>th token in <var>tokens</var> is an <span>ASCII case-insensitive</span> match for one of the strings in
55760+
the following list, then run the substeps that follow:</p>
55761+
55762+
<ul class="brief">
55763+
<li>"<code data-x="attr-fe-autocomplete-home">home</code>"
55764+
<li>"<code data-x="attr-fe-autocomplete-work">work</code>"
55765+
<li>"<code data-x="attr-fe-autocomplete-mobile">mobile</code>"
55766+
<li>"<code data-x="attr-fe-autocomplete-fax">fax</code>"
55767+
<li>"<code data-x="attr-fe-autocomplete-pager">pager</code>"
55768+
</ul>
55769+
55770+
<p>The substeps are:</p>
55771+
55772+
<ol>
55773+
<li><p>Let <var>contact</var> be the matching string from the list above.</p></li>
55774+
55775+
<li><p>Insert <var>contact</var> at the start of <var>scope
55776+
tokens</var>.</p></li>
55777+
55778+
<li><p>Add <var>contact</var> to <var>hint tokens</var>.</p></li>
55779+
55780+
<li><p>Let <var>IDL value</var> be the concatenation of <var>contact</var>, a
55781+
U+0020 SPACE character, and the previous value of <var>IDL value</var>.</p></li>
55782+
55783+
<li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
55784+
entry, then skip to the step labeled <i>done</i>.</p></li>
55785+
55786+
<li><p>Decrement <var>index</var> by one.</p></li>
55787+
</ol>
55788+
</li>
55789+
55790+
<li>
55791+
<p>If the <var>index</var>th token in <var>tokens</var> is an <span>ASCII
55792+
case-insensitive</span> match for one of the strings in the following list, then run the
55793+
substeps that follow:</p>
55794+
55795+
<ul class="brief">
55796+
<li>"<code data-x="attr-fe-autocomplete-shipping">shipping</code>"
55797+
<li>"<code data-x="attr-fe-autocomplete-billing">billing</code>"
55798+
</ul>
55799+
55800+
<p>The substeps are:</p>
55801+
55802+
<ol>
55803+
<li><p>Let <var>mode</var> be the matching string from the list above.</p></li>
55804+
55805+
<li><p>Insert <var>mode</var> at the start of <var>scope
55806+
tokens</var>.</p></li>
55807+
55808+
<li><p>Add <var>mode</var> to <var>hint tokens</var>.</p></li>
55809+
55810+
<li><p>Let <var>IDL value</var> be the concatenation of <var>mode</var>, a
55811+
U+0020 SPACE character, and the previous value of <var>IDL value</var>.</p></li>
55812+
55813+
<li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
55814+
entry, then skip to the step labeled <i>done</i>.</p></li>
55815+
55816+
<li><p>Decrement <var>index</var> by one.</p></li>
55817+
</ol>
55818+
</li>
55819+
55820+
<li><p>If the <var>index</var>th entry in <var>tokens</var> is not the first entry, then jump to
55821+
the step labeled <i>default</i>.</p></li>
55822+
55823+
<li><p>If the first eight characters of the <var>index</var>th token in <var>tokens</var> are not
55824+
an <span>ASCII case-insensitive</span> match for the string "<code
55825+
data-x="attr-fe-autocomplete-section">section-</code>", then jump to the step labeled
55826+
<i>default</i>.</p></li>
55827+
55828+
<li><p>Let <var>section</var> be the <var>index</var>th token in <var>tokens</var>,
55829+
<span>converted to ASCII lowercase</span>.</p></li>
55830+
55831+
<li><p>Insert <var>section</var> at the start of <var>scope tokens</var>.</p></li>
55832+
55833+
<li><p>Let <var>IDL value</var> be the concatenation of <var>section</var>, a U+0020 SPACE
55834+
character, and the previous value of <var>IDL value</var>.</p></li>
55835+
55836+
<li><p><i>Done</i>: Let the element's <span>autofill hint set</span> be <var>hint
55837+
tokens</var>.</p>
55838+
55839+
<li><p>Let the element's <span>non-autofill credential type</span> be <var>credential
55840+
type</var>.</p></li>
55841+
55842+
<li><p>Let the element's <span>autofill scope</span> be <var>scope tokens</var>.</p>
55843+
55844+
<li><p>Let the element's <span>autofill field name</span> be <var>field</var>.</p>
55845+
55846+
<li><p>Let the element's <span>IDL-exposed autofill value</span> be <var>IDL value</var>.</p>
55847+
55848+
<li><p>Return.</p></li>
55849+
55850+
<li><p><i>Default</i>: Let the element's <span>IDL-exposed autofill value</span> be the empty
55851+
string, and its <span>autofill hint set</span> and <span>autofill scope</span> be empty.</p></li>
55852+
55853+
<li><p>If the element's <code data-x="attr-fe-autocomplete">autocomplete</code> attribute is
55854+
wearing the <span>autofill anchor mantle</span>, then let the element's <span>autofill field
55855+
name</span> be the empty string and return.</p></li>
55856+
55857+
<li><p>Let <var>form</var> be the element's <span>form owner</span>, if any, or null
55858+
otherwise.</p></li>
55859+
5569255860
<li>
55693-
<p>If the <var>index</var>th token in <var>tokens</var> is not an <span>ASCII
55694-
case-insensitive</span> match for one of the tokens given in the first column of the following
55695-
table, or if the number of tokens in <var>tokens</var> is greater than the maximum
55696-
number given in the cell in the second column of that token's row, then jump to the step labeled
55697-
<i>default</i>. Otherwise, let <var>field</var> be the string given in the cell of the
55698-
first column of the matching row, and let <var>category</var> be the value of the cell
55699-
in the third column of that same row.</p>
55861+
<p>If <var>form</var> is not null and <var>form</var>'s <code
55862+
data-x="attr-form-autocomplete">autocomplete</code> attribute is in the <span
55863+
data-x="attr-form-autocomplete-off-state">off</span> state, then let the element's
55864+
<span>autofill field name</span> be "<code data-x="attr-fe-autocomplete-off">off</code>".</p>
55865+
55866+
<p>Otherwise, let the element's <span>autofill field name</span> be "<code
55867+
data-x="attr-fe-autocomplete-on">on</code>".</p>
55868+
</li>
55869+
</ol>
55870+
55871+
<p>To <dfn>determine a field's category</dfn>, given <var>field</var>:</p>
55872+
55873+
<ol>
55874+
<li>
55875+
<p>If the <var>field</var> is not an <span>ASCII case-insensitive</span> match for one of the
55876+
tokens given in the first column of the following table, return the pair (null, null).</p>
5570055877

5570155878
<table>
5570255879
<thead>
@@ -55939,158 +56116,10 @@ MIT Room 32-G524
5593956116
</table>
5594056117
</li>
5594156118

55942-
<li><p>If <var>category</var> is Off or Automatic but the element's <code
55943-
data-x="attr-fe-autocomplete">autocomplete</code> attribute is wearing the <span>autofill anchor
55944-
mantle</span>, then jump to the step labeled <i>default</i>.</p></li>
55945-
55946-
<li><p>If <var>category</var> is Off, let the element's <span>autofill field name</span>
55947-
be the string "<code data-x="">off</code>", let its <span>autofill hint set</span> be empty, and
55948-
let its <span>IDL-exposed autofill value</span> be the string "<code data-x="">off</code>". Then,
55949-
return.</p>
55950-
55951-
<li><p>If <var>category</var> is Automatic, let the element's <span>autofill field
55952-
name</span> be the string "<code data-x="">on</code>", let its <span>autofill hint set</span> be
55953-
empty, and let its <span>IDL-exposed autofill value</span> be the string "<code
55954-
data-x="">on</code>". Then, return.</p>
55955-
55956-
<li><p>Let <var>scope tokens</var> be an empty list.</p></li>
55957-
55958-
<li><p>Let <var>hint tokens</var> be an empty set.</p></li>
55959-
55960-
<li><p>Let <var>credential type</var> be null.</p></li>
55961-
55962-
<li><p>Let <var>IDL value</var> have the same value as <var>field</var>.</p></li>
55963-
55964-
<li>
55965-
<p>If <var>category</var> is Credential and the <var>index</var>th token in <var>tokens</var> is
55966-
an <span>ASCII case-insensitive</span> match for "<code
55967-
data-x="attr-fe-autocomplete-webauthn">webauthn</code>", then run the substeps that follow:</p>
55968-
<ol>
55969-
<li><p>Set <var>credential type</var> to "<code data-x="">webauthn</code>".</p></li>
55970-
<li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
55971-
then skip to the step labeled <i>done</i>.</p></li>
55972-
<li><p>Decrement <var>index</var> by one.</p></li>
55973-
</ol>
55974-
</li>
55975-
55976-
<li><p>If the <var>index</var>th token in <var>tokens</var> is the first entry,
55977-
then skip to the step labeled <i>done</i>.</p></li>
55978-
55979-
<li><p>Decrement <var>index</var> by one.</p></li>
55980-
55981-
<li>
55982-
<p>If <var>category</var> is Contact and the <var>index</var>th token in <var>tokens</var> is an <span>ASCII case-insensitive</span> match for one of the strings in
55983-
the following list, then run the substeps that follow:</p>
55984-
55985-
<ul class="brief">
55986-
<li>"<code data-x="attr-fe-autocomplete-home">home</code>"
55987-
<li>"<code data-x="attr-fe-autocomplete-work">work</code>"
55988-
<li>"<code data-x="attr-fe-autocomplete-mobile">mobile</code>"
55989-
<li>"<code data-x="attr-fe-autocomplete-fax">fax</code>"
55990-
<li>"<code data-x="attr-fe-autocomplete-pager">pager</code>"
55991-
</ul>
56119+
<li><p>Otherwise, let <var>maximum tokens</var> and <var>category</var> be the values of the
56120+
cells in the second and third columns of that row respectively.</p></li>
5599256121

55993-
<p>The substeps are:</p>
55994-
55995-
<ol>
55996-
<li><p>Let <var>contact</var> be the matching string from the list above.</p></li>
55997-
55998-
<li><p>Insert <var>contact</var> at the start of <var>scope
55999-
tokens</var>.</p></li>
56000-
56001-
<li><p>Add <var>contact</var> to <var>hint tokens</var>.</p></li>
56002-
56003-
<li><p>Let <var>IDL value</var> be the concatenation of <var>contact</var>, a
56004-
U+0020 SPACE character, and the previous value of <var>IDL value</var> (which at this
56005-
point will always be <var>field</var>).</p></li>
56006-
56007-
<li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
56008-
entry, then skip to the step labeled <i>done</i>.</p></li>
56009-
56010-
<li><p>Decrement <var>index</var> by one.</p></li>
56011-
</ol>
56012-
</li>
56013-
56014-
<li>
56015-
<p>If the <var>index</var>th token in <var>tokens</var> is an <span>ASCII
56016-
case-insensitive</span> match for one of the strings in the following list, then run the
56017-
substeps that follow:</p>
56018-
56019-
<ul class="brief">
56020-
<li>"<code data-x="attr-fe-autocomplete-shipping">shipping</code>"
56021-
<li>"<code data-x="attr-fe-autocomplete-billing">billing</code>"
56022-
</ul>
56023-
56024-
<p>The substeps are:</p>
56025-
56026-
<ol>
56027-
<li><p>Let <var>mode</var> be the matching string from the list above.</p></li>
56028-
56029-
<li><p>Insert <var>mode</var> at the start of <var>scope
56030-
tokens</var>.</p></li>
56031-
56032-
<li><p>Add <var>mode</var> to <var>hint tokens</var>.</p></li>
56033-
56034-
<li><p>Let <var>IDL value</var> be the concatenation of <var>mode</var>, a
56035-
U+0020 SPACE character, and the previous value of <var>IDL value</var> (which at this
56036-
point will either be <var>field</var> or the concatenation of <var>contact</var>, a space, and <var>field</var>).</p></li>
56037-
56038-
<li><p>If the <var>index</var>th entry in <var>tokens</var> is the first
56039-
entry, then skip to the step labeled <i>done</i>.</p></li>
56040-
56041-
<li><p>Decrement <var>index</var> by one.</p></li>
56042-
</ol>
56043-
</li>
56044-
56045-
<li><p>If the <var>index</var>th entry in <var>tokens</var> is not the first entry, then jump to
56046-
the step labeled <i>default</i>.</p></li>
56047-
56048-
<li><p>If the first eight characters of the <var>index</var>th token in <var>tokens</var> are not
56049-
an <span>ASCII case-insensitive</span> match for the string "<code
56050-
data-x="attr-fe-autocomplete-section">section-</code>", then jump to the step labeled
56051-
<i>default</i>.</p></li>
56052-
56053-
<li><p>Let <var>section</var> be the <var>index</var>th token in <var>tokens</var>,
56054-
<span>converted to ASCII lowercase</span>.</p></li>
56055-
56056-
<li><p>Insert <var>section</var> at the start of <var>scope tokens</var>.</p></li>
56057-
56058-
<li><p>Let <var>IDL value</var> be the concatenation of <var>section</var>, a U+0020 SPACE
56059-
character, and the previous value of <var>IDL value</var>.</p></li>
56060-
56061-
<li><p><i>Done</i>: Let the element's <span>autofill hint set</span> be <var>hint
56062-
tokens</var>.</p>
56063-
56064-
<li><p>Let the element's <span>non-autofill credential type</span> be <var>credential
56065-
type</var>.</p></li>
56066-
56067-
<li><p>Let the element's <span>autofill scope</span> be <var>scope tokens</var>.</p>
56068-
56069-
<li><p>Let the element's <span>autofill field name</span> be <var>field</var>.</p>
56070-
56071-
<li><p>Let the element's <span>IDL-exposed autofill value</span> be <var>IDL value</var>.</p>
56072-
56073-
<li><p>Return.</p></li>
56074-
56075-
<li><p><i>Default</i>: Let the element's <span>IDL-exposed autofill value</span> be the empty
56076-
string, and its <span>autofill hint set</span> and <span>autofill scope</span> be empty.</p></li>
56077-
56078-
<li><p>If the element's <code data-x="attr-fe-autocomplete">autocomplete</code> attribute is
56079-
wearing the <span>autofill anchor mantle</span>, then let the element's <span>autofill field
56080-
name</span> be the empty string and return.</p></li>
56081-
56082-
<li><p>Let <var>form</var> be the element's <span>form owner</span>, if any, or null
56083-
otherwise.</p></li>
56084-
56085-
<li>
56086-
<p>If <var>form</var> is not null and <var>form</var>'s <code
56087-
data-x="attr-form-autocomplete">autocomplete</code> attribute is in the <span
56088-
data-x="attr-form-autocomplete-off-state">off</span> state, then let the element's
56089-
<span>autofill field name</span> be "<code data-x="attr-fe-autocomplete-off">off</code>".</p>
56090-
56091-
<p>Otherwise, let the element's <span>autofill field name</span> be "<code
56092-
data-x="attr-fe-autocomplete-on">on</code>".</p>
56093-
</li>
56122+
<li><p>Return the pair (<var>category</var>, <var>maximum tokens</var>).</p></li>
5609456123
</ol>
5609556124

5609656125
<hr>

0 commit comments

Comments
 (0)