You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apreq-dev@httpd.apache.org by Rob Mueller <ro...@fastmail.fm> on 2004/04/08 23:25:07 UTC

Missing submit button if after a file field

I'm seeing an odd problem with libapreq 1.3 (mod_perl2 just isn't quite
mature enough yet...) and buttons on a form with file upload fields.
Basically it seems that a browser that submits the button field immediately
after a file upload field on a form, the button value disappears from the
params() result in libapreq. It's probably best to show what's going on with
an example:

I put this in my usual conf/perl.conf setup...

<Location /test>
  SetHandler perl-script
  PerlHandler main::test
<Perl>
package main;
use Apache::Request;
use Data::Dumper;
sub test {
  my $R = shift;

#  my $R = Apache::Request->new($R);
#  $Status = $R->parse;
#  my %Params = map { $_ => $R->param($_) } $R->param;
#  warn Dumper(\%Params);

   chomp($_ = <STDIN>);
   while ($_) { warn "$_\n"; chomp($_ = <STDIN>); }

  $R->content_type('text/html');
  $R->send_http_header;

  print <<'EOF';
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html> <head> <title>Test</title> </head> <body>
<form method="post" action="http://localhost:8080/test/"
enctype="multipart/form-data">
<input type="submit" name="somename" value="Click"><br>
<input type="file" name="FMC-UploadFile1" size="20"><br>
<input type="submit" name="somename" value="Click"><br>
</form> </body> </html>
EOF

  return Apache::OK;
}
</Perl>
</Location>


If I click the first button, in the log I see:

------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp
Content-Disposition: form-data; name="somename"

Click
------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp
Content-Disposition: form-data; name="FMC-UploadFile1"; filename=""

------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp--

No problem. If I click the second button, in the log I see:

------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq
Content-Disposition: form-data; name="FMC-UploadFile1"; filename=""

------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq
Content-Disposition: form-data; name="somename"

Click
------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq--

Also apparently no problem, the actual data is there. Ok, now if I change
the code so that it uses libapreq to parse the params instead for just
"warning" them out to the log (just uncomment the commented out lines above,
and comment out the 'while' line beneath them). If I click the first button,
I see:

$VAR1 = {
  'somename' => 'Click',
  'FMC-UploadFile1' => ''
};

Which is good. But if I click the second button I see:

$VAR1 = {
  'FMC-UploadFile1' => ''
};

Ah, the button has disappeared!

To be honest, I haven't dug through the spec to see if buttons are supposed
to come before other fields, but as far as I can tell, this problem only
happens if the button field is submitted by the browser immediately after a
file field, and at the moment the only browser I've seen do that is
Konquerer.

Anybody know what's broken here? Is it libapreq? Is it Konquerer?

Rob



Re: Missing submit button if after a file field

Posted by Issac Goldstand <ma...@beamartyr.net>.
Agreed

----- Original Message ----- 
From: "Joe Schaefer" <jo...@sunstarsys.com>
To: <ap...@httpd.apache.org>
Sent: Friday, April 09, 2004 8:04 PM
Subject: Re: Missing submit button if after a file field


> Joe Schaefer <jo...@sunstarsys.com> writes:
> 
> [...]
> 
> > I suspect that libapreq isn't able to handle the empty file block
> > that Konqueror is generating.  I'll check the RFC, but my first
> > reaction to your posted data is that there's an "\r\n" missing in 
> > Konqueror's output.  
> 
> Looking carefully at the BNF in 2046, Section 5.1.1 has
> 
>     body-part := MIME-part-headers [CRLF *OCTET]
> 
> AFAICT, this implies Konqueror's missing CRLF still complies with 2046,
> because CRLF is an optional component of the body-part when there's no
> file data available (the *OCTET portion).
> 
> Does anyone else agree with my reading?
> 
> -- 
> Joe Schaefer
> 

Re: Missing submit button if after a file field

Posted by Joe Schaefer <jo...@sunstarsys.com>.
Joe Schaefer <jo...@sunstarsys.com> writes:

[...]

> I suspect that libapreq isn't able to handle the empty file block
> that Konqueror is generating.  I'll check the RFC, but my first
> reaction to your posted data is that there's an "\r\n" missing in 
> Konqueror's output.  

Looking carefully at the BNF in 2046, Section 5.1.1 has

    body-part := MIME-part-headers [CRLF *OCTET]

AFAICT, this implies Konqueror's missing CRLF still complies with 2046,
because CRLF is an optional component of the body-part when there's no
file data available (the *OCTET portion).

Does anyone else agree with my reading?

-- 
Joe Schaefer


Re: Missing submit button if after a file field

Posted by Joe Schaefer <jo...@sunstarsys.com>.
"Rob Mueller" <ro...@fastmail.fm> writes:

[...]

> If I click the first button, in the log I see:
> 
> ------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp
> Content-Disposition: form-data; name="somename"
> 
> Click
> ------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp
> Content-Disposition: form-data; name="FMC-UploadFile1"; filename=""
> 
> ------------jZLJfj7sG9kLeKXzCBVikO7gXcwytA8ahRtMA1FQAxjmGHkSSF9AbEp--
> 
> No problem. If I click the second button, in the log I see:
> 
> ------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq
> Content-Disposition: form-data; name="FMC-UploadFile1"; filename=""
> 
> ------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq
> Content-Disposition: form-data; name="somename"
> 
> Click
> ------------bQaJLMV8JU2DxyhdPfNYApBF5BDgYSk7tIRCewKvOK6LInxiTKEb8Pq--
> 
> Also apparently no problem, the actual data is there. 

I suspect that libapreq isn't able to handle the empty file block
that Konqueror is generating.  I'll check the RFC, but my first
reaction to your posted data is that there's an "\r\n" missing in 
Konqueror's output.  Mozilla 0.97 had the same problem; recall

  http://marc.theaimsgroup.com/?l=apache-modperl&m=101295988431701&w=2

-- 
Joe Schaefer