Skip Menu |

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 61499
Status: rejected
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: perl [...] evancarroll.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.80027
Fixed in: (no value)



Subject: HTML5 bug, $c->req->uploads will return a scalar if there is one upload
HTML5 introduces `multiple` on form uploads, unfortunately the browser doesn't transmit anything to indicate that the type is multiple. -----------------------------18910739318893266631096981613 Content- Disposition: form-data; name="picture[]"; filename="3a97abfcccdb1067d3f1db01acc0d2cf.jpg" Content-Type: image/jpeg Here is an example of this html5 tag. <input type="file" name="upload[]" multiple="true"> By convention this tag seems to use /[]$/ suffix in the name. So I'm going to make the suggestion that all $c->req->uploads that end in /[]$/ be of type ArrayRef rather than Scalar. Currently, if you upload one file $c->req->upload('upload[]') will be a scalar, and if you upload more than one $c->req->upload('upload[]') will be an array ref. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
This would break almost every application using $c->req->upload, so no...
On Tue Sep 21 04:58:06 2010, BOBTFISH wrote: Show quoted text
> This would break almost every application using $c->req->upload, so
no... How is that I'm asking that it only work key/value pairs where the key ends in /[]$/ -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
On Tue Sep 21 10:35:06 2010, ECARROLL wrote: Show quoted text
> On Tue Sep 21 04:58:06 2010, BOBTFISH wrote:
> > This would break almost every application using $c->req->upload, so
> no... > > How is that I'm asking that it only work key/value pairs where the key > ends in /[]$/
Would http://search.cpan.org/perldoc?Catalyst::Plugin::Params::Nested do this for you? I know it does similar sort of things
Show quoted text
> Would http://search.cpan.org/perldoc?Catalyst::Plugin::Params::Nested > do this for you? I know > it does similar sort of things
As is, no C:P:P:N does not do this. In fact, I wrote the last version to explicitly not needlessly touch keys ending in "[]". (http://cpansearch.perl.org/src/BOBTFISH/Catalyst-Plugin-Params-Nested- 0.04/Changes). And, at that just a remind there is an open patch I submitted to remove the Test::MO crap from C:P:P:N, and use Catalyst::Test instead: https://rt.cpan.org/Ticket/Display.html?id=61066 The chances of us breaking backwards compat in the real world with upload params that end in an empty "[]" are so minuscule that it doesn't even matter... Who would randomly end their key with "[]" that wasn't looking for trouble or desiring the convention's behavior? The alternative -- to leave this untouched -- will result in the HTML5 convention just getting in the way. It requires everyone to special case the potential single-file upload on a multi-file capable field.. -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
HTML5 The Catalyst Way!!! my $pictureOrder = delete $c->req->params->{'pictureOrder[]'}; my $picture = delete $c->req->uploads->{'picture[]'}; unless ( ref $picture eq 'ARRAY' ) { $picture = [$picture] if defined $picture; } unless ( ref $pictureOrder eq 'ARRAY' ) { $pictureOrder = [$pictureOrder] if defined $picture; } -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
I don't think supporting form fields with [] as a convention to indicate array is a good concept for catalyst core. I'm closing this but I encourage people to think about how to normalize this in the extended ecosystem