I am running into an encoding problem with form parameter values that
contain non-ASCII characters in a form that contains an upload
component. Without the upload component everything works fine. The
problem appears to be in the handling of strings in
'multipart/form-data', in that both Firefox and Mozilla seem to send
strings encoded as UTF-8, but don't specify a character set, and the
upload component interprets these as ISO-8559-1. This actually seems to
be the correct response to incorrect behavior by the browsers, but in
practice we need to find a workaround. I can't find a way to get around
this without modifying the tapestry-upload project, and I was wondering
if anyone could suggest a better solution, and if not whether Tapestry
itself will deal with this in the future

Our simple, hack workaround is to modify
'MultipartDecoderImpl.processFileItems(...)' to call

wrapper.addParameter(item.getFieldName(), item.getString("UTF8"))

instead of

wrapper.addParameter(item.getFieldName(), item.getString())

To improve this, I think we would need

1) To have a way of passing in an appropriate default encoding to use.
We could contribute a 'HttpServletRequestHandler' that sets the
request's default character encoding, but is there a way to guarantee
that our handler would be called before the
'MultipartServletRequestFilter'?

2) Even if did (1), we would need a way to use this encoding to parse
strings multipart form fields. Passing the encoding to
'FileItem.getString()' is undesirable because it would not handle the
case where the part's 'charset' parameter was explicitly set. The
parameterless version of 'FileItem.getString()' cannot be used, however,
because it explicitly defaults to 'ISO-8859-1' if the character set is
not specified (e.g. it uses neither the request's character encoding or
the header encoding set by 'FileUpload.setHeaderEncoding'). I can't find
a nice way to do this without duplicating some code in
'commons-fileupload' or relying on public methods of 'DiskFileItem' that
aren't in the 'FileItem' interface.

Thanks,
Doug



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

Reply via email to