cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Geoff Howard <cocoonge...@yahoo.com>
Subject RE: enctype="multipart/form-data" problem
Date Tue, 12 Nov 2002 15:20:49 GMT
It is already fixed in 2.0.3, the release version:

    private Hashtable readHeaders(TokenStream in)
throws IOException {

        Hashtable headers = new Hashtable();
        String hdrline = readln(in);

        while (!"".equals(hdrline)) {
            StringTokenizer tokenizer = new
StringTokenizer(hdrline);

            headers.put(tokenizer.nextToken("
:").toLowerCase(),
                        tokenizer.nextToken(" :;"));

	        // The extra tokenizer.hasMoreTokens() in
headers.put
	        // handles the filename="" case IE6 submits
for an empty
	        // upload field.
            while (tokenizer.hasMoreTokens()) {
                headers.put(tokenizer.nextToken("
;=\""),
                            tokenizer.hasMoreTokens()
? tokenizer.nextToken("=\"") : "");
            }

            hdrline = readln(in);
        }

        return headers;
    }


--- Volker Schneider <volker.schneider@danet.de>
wrote:
> Hi myself,
> 
> this is a bug in MultipartParser.java in the
> readHeaders() method within
> Cocoon 2.0.2.
> 
> When you define <form name="form2"
> enctype="multipart/form-data"
> method="post"> and you use a <input
> name="uploadedfile" type="file"> field,
> the header will contain:
> 
> ...name="uploadedfile"; filename=""
> 
> When filename is empty the StringTokenizer in
> readHeaders() will have no
> more tokens, but will get a nextToken() call.
> 
> Here's an approach for a bug fix:
> 
> ...
> while (tokenizer.hasMoreTokens())
> {
>   //---- old code
>   //  headers.put(tokenizer.nextToken(" ;=\""),
>   //          tokenizer.nextToken("=\""));
> 
>   //---- new code
>   String key = tokenizer.nextToken(" ;=\"");
>   String value = "";
>   if (tokenizer.hasMoreTokens())
>   {
>     value = tokenizer.nextToken("=\"");
>   }
>   else
>   {
>     value = "";
>   }
> 
>   headers.put(key, value);
>   //---- end of new code
> }
> 
> This helps unless the filename="" is not followed by
> an additional
> attribute, but it helps for the moment.
> 
> Please fix this bug, if it is not done yet.
> 
> Best regards
> - Volker -
> 
> 
> -----Original Message-----
> From: Volker Schneider
> [mailto:volker.schneider@danet.de]
> Sent: Sonntag, 10. November 2002 22:32
> To: cocoon-users@xml.apache.org
> Subject: enctype="multipart/form-data" problem
> 
> 
> Dear colleagues,
> 
> if have a form and I want to upload a file from that
> form. When I define my
> form as
> 
> <form name="form2" enctype="multipart/form-data"
> method="post">
> 
> the ordinary input fields will not be transferred.
> 
> When I use method="get" it works. Unfortunately I
> have to use the "post"
> method because I have to transfer a lot of data and
> I'm not sure, whether
> this is possible with the "get" method (because of
> limited URL length).
> 
> Splitting the form is not possible, because I need
> the rest of the data too.
> 
> Please help me, what can I do?
> 
> Thank you, best regards
> - Volker -
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:  
> <cocoon-users-help@xml.apache.org>
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <cocoon-users-unsubscribe@xml.apache.org>
> For additional commands, e-mail:  
> <cocoon-users-help@xml.apache.org>
> 


__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <cocoon-users-unsubscribe@xml.apache.org>
For additional commands, e-mail:   <cocoon-users-help@xml.apache.org>


Mime
View raw message