Are HTML user agents required to submit form data in a specific order?

For this HTML form, is it a user agent that needs to create a submit request in a specific order?

I looked at the HTML 4.0.1 specification and did not seem to indicate the order in which "successful control" becomes part of the request upon presentation. Section 17.13.3 , Processing of form, state data:

When a user submits a form (for example, by activating a submit button), the user agent processes it as follows.

Step One: Identify Successful Controls

Step Two: Create a Form Dataset

The form dataset is a sequence of control-name / current-value built from successful controls

Step three: encode the form dataset

The form dataset is then encoded according to the content type specified by the enctype attribute of the enctype element.

Step Four: Submit the Coded Form Dataset

In the second step, the form data set is described as a sequence, so the order in which it is encoded in step 3 is presumably fixed. But this raises the question of what order of successful controls is in the form dataset.

For example, given the following HTML form:

 <form action="#" method="GET"> <input type="hidden" name="key1" value="value1" /> <div> <div> <input type="hidden" name="key2" value="value2" /> </div> <input type="hidden" name="key3" value="value3" /> <input type="submit" name="submit" value="Submit" /> </div> <input type="hidden" name="key5" value="value5" /> </form> 

Can a form dataset be

<< 23>, "value3" ), ( "key3" , "value3" ), ( "submit" , "submit" ), ( "key5" , "value5" )]

(Ie - search in depth DOM depth); or

<, "value5" ), ( "key3" , "value3" ), ( "submit" , "submit" ), ( "key2" , "value2" )]

(width search); or even a non-deterministic order resulting from iterating control-name / current-value pairs in a randomized hash table?

Testing this form with IE 9 and Firefox 9.0.1, it looks like both use the depth search order. Other browsers may be different. The question is, somewhere this order is prescribed.

+4
source share
1 answer

If you continue to section 17.13.4 of the HTML specification , it states that the default content type is application/x-www-form-urlencoded . The section for this type of content says:

The names / values โ€‹โ€‹of the controls are listed in the order in which they appear in the document .

This would suggest a workaround for depth and would seem to agree with your browser checks.

+7
source

Source: https://habr.com/ru/post/1388766/


All Articles