Do browsers support input order with the same name in GET / POST?

I have this HTML with multiple input with the same name:

 <input type="hidden" value="42" name="authors" /> <input type="hidden" value="13" name="authors" /> <input type="hidden" value="33" name="authors" /> 

The order of values ​​is important. Does the HTML specification specify that user agents should maintain this order, and if so, do common browsers (market shares> 1%) use this definition?

Bonus points if someone knows if WSGI and especially Django support the server side of the order :-)

Thank!

+29
html cross-browser wsgi
Oct 26 '10 at 20:18
source share
2 answers

Yes, they must be sent in the order they appear according to the HTML RFC

See 8.2.1. Urlencoded encoded media form:

Fields are listed in the order they appear in the document with a name separated by a = symbol and pairs separated by & . Fields with zero values ​​may be omitted. In particular, unselected radio buttons and flags should not appear in the encoded data, and hidden fields with VALUE attributes should be present.

I found in the specification for HTML 4.0 too:

For URL-encoded data:

The names / values ​​of the controls are listed in the order they appear in the document. The name is separated from the value by the symbol = and the name / value pairs are separated from each other by the & sign.

For composite data (thanks @Chuck):

The "multipart / form-data" message contains a series of parts, each of which represents a successful control. Parts are sent to the processing agent in the same order in which the corresponding controls are displayed in the document flow. Part boundaries should not be found in any of the data; how this is done is beyond the scope of this specification.

+35
Oct 26 '10 at 20:26
source share

the HTML5 specification for application/x-www-form-urlencoded and text/plain sets out an algorithm that "Add [...] for each record in a form dataset", which leads to the same order.

As for multipart/form-data : "The order of the parts should be the same as the order of the fields in the form data set. Several records with the same name should be treated as different fields."

This would not be complete without obtaining the order of the form dataset obtained from the document: the same spec defines the algorithm for constructing the form dataset that "Loop: for each field of the element in the controls, in tree order, perform the following substeps and skip or add record.

Therefore, for user agents that are compatible with HTML5, no matter what encoding, the missing parameters are ordered by tree, with valid duplicates .

+2
Apr 23 '15 at 9:12
source share



All Articles