Skip to content

[BrowserKit] do not try to read from empty filenames #53586

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
wants to merge 1 commit into from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Jan 19, 2024

Q A
Branch? 5.4
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #49014
License MIT

@rudiedirkx
Copy link

rudiedirkx commented Jan 19, 2024

This does fix the exception from #49014 BUT it doesn't do what a browser does, and it might break the application behind the form. Instead of sending an empty/non-file, it sends the file field as a normal field with empty string:

$_POST:
Array
(
    [op] => Submit it
    [values] => Array
        (
            [text] => Oele
        )
    [file] => 
)

(see the [file]) What it should do is what a real browser does: send a non-file, or whatever you would call that:

$_POST:
Array
(
    [op] => Submit it
    [values] => Array
        (
            [text] => asd
        )
)

$_FILES:
Array
(
    [file] => Array
        (
            [name] => 
            [full_path] => 
            [type] => 
            [tmp_name] => 
            [error] => 4
            [size] => 0
        )
)

file is in the $_FILES list, with error 4: UPLOAD_ERR_NO_FILE: https://www.php.net/manual/en/features.file-upload.errors.php#features.file-upload.errors That's what happens if you submit a file field without file.

IMO deleting the file from the form is a better solution than the empty string, but sending the non-file would be even more realistic, but I don't know how symfony/curl would do that.

@fabpot fabpot modified the milestones: 5.4, 6.4 Dec 14, 2024
@nicolas-grekas
Copy link
Member

Closing in favor of #59752, thanks for having a look!

@xabbuh xabbuh deleted the issue-49014 branch February 11, 2025 13:10
nicolas-grekas added a commit that referenced this pull request Feb 11, 2025
…nicolas-grekas)

This PR was merged into the 6.4 branch.

Discussion
----------

[BrowserKit] Fix submitting forms with empty file fields

| Q             | A
| ------------- | ---
| Branch?       | 6.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #49014
| License       | MIT

Replaces #53586 and #59621

Commits
-------

0fbfc3e [BrowserKit] Fix submitting forms with empty file fields
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants