Skip to content

[Form] Files upload is broken for PHP 8.1 because of new key full_path is added #46146

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
p-golovin opened this issue Apr 22, 2022 · 2 comments
Closed

Comments

@p-golovin
Copy link
Contributor

Symfony version(s) affected

5.4.7, 6.0.7, 6.1

Description

There is hardcoded array of keys for $_FILES in https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php.

It is checked against posted data in two cases:
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L204
https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L240

In PHP 8.1 was added new key full_path (https://php.watch/versions/8.1/$_FILES-full-path). As a result check is broken and we get incorrect format of image's array at https://github.com/symfony/symfony/blob/5.4/src/Symfony/Component/Form/NativeRequestHandler.php#L93 and error that form contains not allowed extra fields.

image

How to reproduce

We use Form component as standalone without entire framework but within our cms. Problem looks obvious, but if it will be needed, I'll try to create code for reproduce problem.

Possible Solution

I've found that such problem was already fixed in HttpFoundation component: #42112

Additional Context

No response

@stof
Copy link
Member

stof commented Apr 22, 2022

Do you want to submit a PR fixing the check ?

@p-golovin
Copy link
Contributor Author

@stof I'll try to make a PR. Will it be good solution to just duplicate unset from HttpFoundation component fix to keep functions logic the same?

fabpot added a commit that referenced this issue Apr 23, 2022
…PHP 8.1 (p-golovin)

This PR was submitted for the 5.4 branch but it was merged into the 4.4 branch instead.

Discussion
----------

Modify processing of uploaded files to be compatible with PHP 8.1

Remove full_path from keys before check
Keep logic the same as in src/Symfony/Component/HttpFoundation/FileBag.php

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Fix #46146
| License       | MIT

Commits
-------

a5cc1e1 Modify processing of uploaded files to be compatible with PHP 8.1
@fabpot fabpot closed this as completed Apr 23, 2022
Largo added a commit to Largo/symfony-http-foundation that referenced this issue May 17, 2022
holdmann pushed a commit to holdmann/symfony-http-foundation that referenced this issue Jun 21, 2024
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

4 participants