DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUGĀ·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=38085>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED ANDĀ·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=38085

           Summary: CGIServlet - form data with enctype="multipart/form-
                    data"
           Product: Tomcat 5
           Version: 5.5.9
          Platform: All
               URL: http://devenezia.com/round-robin/forum/postenvTAKEOUT.pl
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Catalina
        AssignedTo: tomcat-dev@jakarta.apache.org
        ReportedBy: [EMAIL PROTECTED]


This information was also posted to Apache-Tomcat listserv.

The sample perl program demonstrates the issue.

When a form has enctype="multipart/form-data" the data on cgi's STDIN (as passed
from cgiservlet) contains the QUERY_STRING in line 1 -- This is wrong.  

If using CGM.pm, it will error with a "Malformed multipart POST" because the
STDIN data and the CONTENT_LENGTH are out of sync. [The content being delivered
on STDIN is now longer than that reported by CONTENT_LENGTH ]

An untested work around (for perlers) is to tweak the perl script:
set content_length = content_length + length(query_string) + 2, iff
x_tomcat_script_path ne "" && content_type =~ #multipart/form-data#

#!c:\usr\bin\perl
##
##  printenv -- demo CGI program which just prints its environment
##

print <<HTML;
Status: 200
Content-type: text/html

<html><body>
<form
action="?ARG1=FOO&ARG2=BAR"
method="post"
enctype="multipart/form-data"
style="float:left"

<input type=text name=A value=123><br>
<input type=text name=B value=456><br>
<input type=text name=C value=789><br>
<input type=text name=D value=314><br>
<input type=text name=E value=123><br>
<input type=text name=F value=456><br>
<input type=text name=G value=789><br>
<input type=text name=H value=314159><br>
<input type=submit>
</form>
HTML

print "<PRE>";
foreach $var (sort(keys(%ENV))) {
    $val = $ENV{$var};
    $val =~ s|\n|\\n|g;
    $val =~ s|"|\\"|g;
    print "${var}=\"${val}\"\n";
}

print "</PRE>";

if ($ENV{'REQUEST_METHOD'} eq "POST") {
    CORE::binmode(STDIN); # good ole dos
    read (STDIN, $post, $ENV{'CONTENT_LENGTH'});
    print "<HR><PRE>!" . $post . "!!! THAT'S ALL FOLKS!</PRE>";

}

print "\n</html></body>";

results in
...
QUERY_STRING="ARG1=FOO&ARG2=BAR"
...
!ARG1=FOO&ARG2=BAR

-----------------------------33251965624481

Content-Disposition: form-data; name="A"

123

-----------------------------33251965624481
dot dot dot
-----------------------------33251965624481

Content-Disposition: form-data; name="H"

314159

-----------------------------3!!! THAT'S ALL FOLKS!

the content delivered to the cgi ends at 3 and 3251965624481<crlf><crlf> has
gone missing, which in turn makes CGI.pm error.

"3251965624481<cr><lf><cr><lf>" is the same length as
"ARG1=FOO&ARG2=BAR"

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to