formic
formic copied to clipboard
merge algorithm output depends on input key order
It looks like the algorithm for merging conflicting usages will produce different results depending on key order:
<form enctype='application/json'>
<input name='mix' value='scalar'>
<input name='mix[0]' value='array 1'>
<input name='mix[key]' value='key key'>
</form>
produces
{
"mix": {
"": "scalar"
, "0": "array 1"
, "key": "key key"
}
}
But:
<form enctype='application/json'>
<input name='mix[0]' value='array 1'>
<input name='mix' value='scalar'>
<input name='mix[key]' value='key key'>
</form>
produces
{
"mix": {
"0": "array 1"
, "1": "scalar"
, "key": "key key"
}
}
This is probably fine when relying on the DOM order on the client, but on the server it can produce seemingly random inconsistencies when using dictionary / hash structures with arbitrary key ordering.
Should the spec be updated to handle this situation?
I came across this when implementing unit tests for Example 7 in Python:
https://github.com/tomchristie/django-rest-framework/pull/2682