Is URL-encoded form data required to be submitted in document order by user agents?

289 Views Asked by At

When a user agent submits url-encoded form data, for example:

<form action="/someaction" method="post" enctype="application/x-www-form-urlencoded">
    <p><label> Order: <input name="order" value="1" /></label></p>
    <p><label> Item: <input name="item" value="item 1" /></label></p>
    <p><label> Item: <input name="item" value="item 2" /></label></p>

    <p><label> Order: <input name="order" value="2" /></label></p>
    <p><label> Item: <input name="item" value="item 3" /></label></p>
    <p><label> Item: <input name="item" value="item 4"/>    
    <input type="submit" value="Submit" />
</form>

Is it required that the user agent, in general, send the data in document order? Example:

order=1&item=item+1&item=item+2&order=2&item=item+3&item=item+4

I have looked at https://url.spec.whatwg.org/#concept-urlencoded, and also read through https://html.spec.whatwg.org/dev/forms.html. But, I am unable to find a definitive answer.

It would seem logical that data is submitted in document order, but perhaps it is not required?

2

There are 2 best solutions below

2
maio290 On

The resource handling the POST request is not aware of the order in the form submitting to it. Therefore it can't know which order would be the correct one and therefore this simply doesn't matter.

0
yas On

After further investigation, it seems the answer is yes -

the construction of the entry list is performed in tree order.