Implemented FR #51634: Can't post multiple fields with the same name#8292
Implemented FR #51634: Can't post multiple fields with the same name#8292derickr wants to merge 1 commit into
Conversation
This PR allows for multiple values with the same field name to be sent to an HTTP server. This server can't be PHP, because PHP's POST processing does not allow for two the same field names. But sending multiple fields with the same name is required for some operations by RFC 7578. This PR allows you to attach an array of values to a field name, and each of these will then be sent as its own distinct multipart/form-data field.
| ] | ||
| ]; | ||
|
|
||
| $options = array( |
There was a problem hiding this comment.
Any reason not to use the short array syntax [] here?
There was a problem hiding this comment.
Not really, I probably copied it from the original example. Will fix.
| } | ||
| #endif | ||
| zend_tmp_string_release(tmp_postval); | ||
| add_simple_field(mime, string_key, current); |
There was a problem hiding this comment.
Nit: An else-case and removing the continue could remove the duplicate zend_string_release_ex.
There was a problem hiding this comment.
Yes, but IMO the current code is more readable, as each special block now looks the same. If we'd to add one in the future, then it's less likely the wrong thing gets copied. (I'm also allergic to else).
|
(I merged this manually) |
|
Will this fix be backported to all currently supported branches or will it only be in PHP >= 8.2? |
|
This only targets the master branch (PHP 8.2). A backport might be considered, but feature requests usually don't get backported to stable versions. |
Of course. But as far as I understand the issue, this (c|sh)ould be considered as bug fix and not as a new feature. What do the release managers of PHP 8.0 and PHP 8.1 think about this? |
|
Wow 12 years almost to the day since I opened that ticket! |
|
I guess you're not seeing notifications of comments on commits so I'll repost this here: This commit introduces a dependency on curl 7.56.0 @derickr - |
Fortunately, this has only been merged into the "master" branch; but still this needs to fixed. Currently, "master" requires libcurl ≥ 7.29.0; lifting a bit might be okay, but 7.56.0 (released 2017-10-04) is likely too much |
|
I don't accept that software released for five years by the time PHP 8.2 comes out is "too new". If distributions bundle that new a version of PHP, then they should also have updated their libcurl. But I should bump the version requirement so that it prevents you from getting a compile error. |
Well, so far our stance was to be rather conservative regarding version requirements of libcurl and other libraries. I think bumping to 7.56.0 should at least be discussed on the internals mailing list. And if we bump, we likely can simplify other parts of ext/curl. |
|
personally I'm fine with whatever requirement you'd want but I'd noticed the careful coding using |
I second that emotion. |
|
@SjonHortensius Yes, but it is nearly impossible to still find a place that has that old of a curl version ;-) In any case: #8460 should fix it. |
|
|
|
||
| SingleValue | ||
| --------------------------%s | ||
| Content-Disposition: form-data; name="multi" |
There was a problem hiding this comment.
@derickr Hi! Sorry to bother you. I am trying to do the same request with PHP 8.2.9, which doesn't work as expected. What I get is that names are overwritten. So, from this particular test, the receiver will only get Multi2 value. Shouldn't the name be name="multi[]" ?
There was a problem hiding this comment.
No, multi is correct; but like the feature description states:
This server can't be PHP, because PHP's POST processing does not allow for two[sic] the same field names.
|
@derickr - Hey! Does this allow us to send multiple files using the same key too, like "file[]" ? I'm using PHP 8.3, but I'm not succeeding in doing this:
Thanks! |
No, this is not (yet) supported. Feel free to file a feature request at https://github.com/php/php-src/issues. |
This PR allows for multiple values with the same field name to be sent to an
HTTP server. This server can't be PHP, because PHP's POST processing does not
allow for two the same field names. But sending multiple fields with the same
name is required for some operations by RFC 7578.
This PR allows you to attach an array of values to a field name, and each of
these will then be sent as its own distinct multipart/form-data field.