php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46745 Multipart/form-data field names truncated at semicolon in certain cases
Submitted: 2008-12-03 21:54 UTC Modified: 2021-05-16 04:22 UTC
Votes:4
Avg. Score:3.8 ± 1.3
Reproduced:3 of 4 (75.0%)
Same Version:1 (33.3%)
Same OS:1 (33.3%)
From: david at sickmiller dot com Assigned: cmb (profile)
Status: No Feedback Package: *General Issues
PHP Version: 5.2.6 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: david at sickmiller dot com
New email:
PHP Version: OS:

 

 [2008-12-03 21:54 UTC] david at sickmiller dot com
Description:
------------
When a form is submitted using multipart-/form-data enctype, PHP will truncate field names if they contain semicolons and certain other characters.  It seems to happen when there is an uneven number of quotation marks that precede the semicolon.

Reproduce code:
---------------
<html><form action="semicolon.php" method="POST" enctype="multipart/form-data">
                <input type="hidden" name="before ; after">
                <input type="hidden" name="&quot; before ; after">
                <input type="hidden" name="' before ; after">
                <input type="hidden" name="' ' before ; after">
                <input type="hidden" name="' &quot; before ; after">
                <input type="hidden" name="&quot; ' before ; after">
                <input type="hidden" name="&quot; &quot; before ; after">
                <input type="hidden" name="&quot; ' ' before ; after">
                <input type="hidden" name="&quot; ' &quot; before ; after">
                <input type="hidden" name="&quot; &quot; ' before ; after">
                <input type="hidden" name="&quot; &quot; &quot; before ; after">
                <input type="hidden" name="' ' ' before ; after">
                <input type="hidden" name="' ' &quot; before ; after">
                <input type="hidden" name="' &quot; ' before ; after">
                <input type="hidden" name="' &quot; &quot; before ; after">
                <input type="submit">
</form><pre><?php
print_r($_POST);
?></pre> </html>


Expected result:
----------------
Array
(
    [before_;_after] => 
    ["_before_;_after] => 
    ['_before_;_after] => 
    ['_'_before_;_after] => 
    ['_"_before_;_after] => 
    ["_'_before_;_after] => 
    ["_"_before_;_after] => 
    ["_'_'_before_;_after] => 
    ["_'_"_before_;_after] => 
    ["_"_'_before_;_after] => 
    ["_"_"_before_;_after] => 
    ['_'_'_before_;_after] => 
    ['_'_"_before_;_after] => 
    ['_"_'_before_;_after] => 
    ['_"_"_before_;_after] => 
)


Actual result:
--------------
Array
(
    [before_;_after] => 
    ["_before_] => 
    ['_before_;_after] => 
    ['_'_before_;_after] => 
    ['_"_before_] => 
    ["_'_before_;_after] => 
    ["_"_before_;_after] => 
    ["_'_'_before_] => 
    ["_'_"_before_;_after] => 
    ["_"_'_before_;_after] => 
    ["_"_"_before_] => 
    ['_'_'_before_;_after] => 
    ['_'_"_before_] => 
    ['_"_'_before_;_after] => 
    ['_"_"_before_;_after] => 
)


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-09 03:49 UTC] david at sickmiller dot com
For a web application, I have written a PHP file that is a general form handler.  Various different forms all post to this same file, which does a foreach through $_POST and essentially produces a table with each field question and answer.  Some of the forms include file uploads, so I have to use multipart/form-data.

The forms are generated dynamically in a moderately expensive operation and result in HTML like this:
<form>
What's your first name? <input name="What's your name?">
</form>

The questions actually come from different systems, so I don't have the flexibility to change them to remove the non-alphanumeric characters.  And it shouldn't be necessary according to the HTML spec.  It's generally been working, except for the peculiar combinations of apostophes, quotation marks, and semicolons that I inadvertently ran into recently and have documented in this bug.  I checked the header, and it looks like Firefox is correctly submitting the data.

I realize this is a niche case.  How difficult does the fix look?
 [2011-04-08 21:51 UTC] jani@php.net
-Package: Feature/Change Request +Package: *General Issues
 [2018-03-11 23:56 UTC] cmb@php.net
-Type: Feature/Change Request +Type: Bug
 [2018-03-11 23:56 UTC] cmb@php.net
Regardless of whether this is a niche case: the described behavior
would be a bug.
 [2021-01-02 14:56 UTC] sji at sj-i dot dev
Couldn't reproduce this on PHP 7.4.

The result on PHP 7.4
-------------------------
Array
(
    [before_;_after] => 
    [%22_before_;_after] => 
    ['_before_;_after] => 
    ['_'_before_;_after] => 
    ['_%22_before_;_after] => 
    [%22_'_before_;_after] => 
    [%22_%22_before_;_after] => 
    [%22_'_'_before_;_after] => 
    [%22_'_%22_before_;_after] => 
    [%22_%22_'_before_;_after] => 
    [%22_%22_%22_before_;_after] => 
    ['_'_'_before_;_after] => 
    ['_'_%22_before_;_after] => 
    ['_%22_'_before_;_after] => 
    ['_%22_%22_before_;_after] => 
)
 [2021-05-03 12:56 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-05-03 12:56 UTC] cmb@php.net
> Couldn't reproduce this on PHP 7.4.

Can anybody else with any of the actively supported PHP
versions[1]?

[1] <https://www.php.net/supported-versions.php>
 [2021-05-16 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC