Foros de discusión

Multipart-Fileupload component in an UTF-8 environment

Markus Maier, modificado hace 11 años.

Multipart-Fileupload component in an UTF-8 environment

New Member Mensajes: 9 Fecha de incorporación: 16/05/12 Mensajes recientes
Hello,

i am using the bridge:inputFile component from the 'http://liferay.com/faces/bridge' taglib in a pure UTF-8 environment.
The component seems to have a problem with special characters (im my case umlauts) that are submitted in normal text input fields along the uploaded files.

The problem is, that the
com.liferay.faces.bridge.context.map.RequestParameterMapMultiPartImpl.RequestParameterMapMultiPartImpl(BridgeContext, ClientDataRequest){
...

			boolean foundAtLeastOneUploadedFile = false;

			if (diskFileItems != null) {

				for (DiskFileItem diskFileItem : diskFileItems) {

					String fieldName = diskFileItem.getFieldName();
					int pos = fieldName.indexOf(namespace);
					if (pos >= 0) {
						fieldName = fieldName.substring(pos + namespace.length());
					}

					if (diskFileItem.isFormField()) {
						[b]String requestParameterValue = diskFileItem.getString();[/b]
						String fixedRequestParameterValue = portletContainer.fixRequestParameterValue(
								requestParameterValue);
						requestParameterMap.put(fieldName, fixedRequestParameterValue);
						logger.debug("{0}=[{1}]", fieldName, fixedRequestParameterValue);
					}
					else {

...
}


always uses the default charset 'ISO-8859-1' from the DiskFileItem class when getting the parameter value (diskFileItem.getString()). This breaks the contents of the UTF-8 encoded textfields.

A possible solution might be passing the correct request encoding to the overloaded method 'public String getString(final String charset);'.

Best regards,

Max
thumbnail
Neil Griffin, modificado hace 11 años.

RE: Multipart-Fileupload component in an UTF-8 environment

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
Hi Max,

Thanks for reporting this problem -- I just created FACES-1242 in order to track this to closure. I happen to be working in that part of the bridge code today and I'll fix it as part of my next commit. I'll let you know when I'm done. Hopefully by close of business today. Lots of file upload refactoring going on because of FACES-1241.

Neil
thumbnail
Neil Griffin, modificado hace 11 años.

RE: Multipart-Fileupload component in an UTF-8 environment

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
OK this should be fixed now. You can download the latest 3.0.0-RC1/3.1.0-RC1 SNAPSHOT versions of the bridge and portlet demos from the snapshot repository.
Markus Maier, modificado hace 11 años.

RE: Multipart-Fileupload component in an UTF-8 environment

New Member Mensajes: 9 Fecha de incorporación: 16/05/12 Mensajes recientes
Hello Neil,

thank you for the quick response and fix, the form fields are now encoded properly!

Best regards,

Max
thumbnail
Neil Griffin, modificado hace 11 años.

RE: Multipart-Fileupload component in an UTF-8 environment

Liferay Legend Mensajes: 2655 Fecha de incorporación: 27/07/05 Mensajes recientes
My pleasure Max -- glad to hear that it's working for you. emoticon