Skip to content

[Mime] Form field values with integer keys not resolved correctly #47504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
claudiu-cristea opened this issue Sep 7, 2022 · 1 comment
Closed

Comments

@claudiu-cristea
Copy link
Contributor

claudiu-cristea commented Sep 7, 2022

Symfony version(s) affected

5.4, 6.2

Description

#38323 introduced the possibility to have multiple parts with the same name. However, this PR added some issues: A from element, such as <input type="hidden" name="bar[0][foo]"> is resolved as bar[foo]. But that is wrong, bar[0][foo] is correct. Also it introduced a limitation in the sense if the field name is actually meant to be an integer, eg the following currently is throwing an exception:

new FormDataPart([
    '1' => [
        'a' => 'one',
        'b' => 'two',
    ],
]);

How to reproduce

Create a form containing

```html
<input type="hidden" name="bar[0][foo]" value="v1">

will resolve as bar[foo].

Then create improve the form as...

<input type="hidden" name="bar[0][foo]" value="v1">
<input type="hidden" name="bar[0][baz]" value="v2">

will throw an exception.

Use the HttpBrowser to post the forms.

Possible Solution

@carsonbot
Copy link

Hey, thanks for your report!
There has not been a lot of activity here for a while. Is this bug still relevant? Have you managed to find a workaround?

nicolas-grekas added a commit that referenced this issue Apr 18, 2023
…rrectly (claudiu-cristea)

This PR was squashed before being merged into the 5.4 branch.

Discussion
----------

[Mime] Form field values with integer keys not resolved correctly

| Q             | A
| ------------- | ---
| Branch?       | 5.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #47504
| License       | MIT
| Doc PR        |

This should be legit:

```
new FormDataPart([
    'qux' => [
        [
            'foo' => 'v1',
            'baz' => 'v2',
        ],
        [
            'foo' => 'v3',
            'baz' => 'v4',
    	],
    ],
]);
```

Fixes #47504

Commits
-------

923de03 [Mime] Form field values with integer keys not resolved correctly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants