You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2010/10/16 20:32:24 UTC

[jira] Issue Comment Edited: (SLING-1845) Parameters encoding wrong

    [ https://issues.apache.org/jira/browse/SLING-1845?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12921730#action_12921730 ] 

Felix Meschberger edited comment on SLING-1845 at 10/16/10 2:32 PM:
--------------------------------------------------------------------

Actually, setting the _charset_ parameter to utf-8 is the right solution. The problem is, that browsers generally don't send the actual content encoding used for POST and _charset_ parameter is the workaround solution.

So to properly submit multi-language forms you should ....

   * send the form to the client with response character encoding UTF-8 (you do that already)
   * set the _charset_ parameter for the form request to the same encoding, UTF-8 in this case.

Browsers will send back form data generally in the same encoding as the encoding in which the form was received from the server. But browsers do not set the character encoding for these requests. So we have to use the _charset_ parameter for Sling to know about this encoding on the form submission.

See also http://sling.apache.org/site/request-parameters.html

      was (Author: fmeschbe):
    Actually, setting the _charset_ parameter to utf-8 is the right solution. The problem is, that browsers generally don't send the actual content encoding used for POST and _charset_ parameter is the workaround solution.

So to properly submit multi-language forms you should ....

   * send the form to the client with response character encoding UTF-8 (you do that already)
   * set the _charset_ parameter for the form request to the same encoding, UTF-8 in this case.

Browsers will send back form data generally in the same encoding as the encoding in which the form was received from the server. But browsers do not set the character encoding for these requests. So we have to use the _charset_ parameter for Sling to know about this encoding on the form submission.
  
> Parameters encoding wrong
> -------------------------
>
>                 Key: SLING-1845
>                 URL: https://issues.apache.org/jira/browse/SLING-1845
>             Project: Sling
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: Commons Mime 2.1.2
>         Environment: Mac OS
>            Reporter: Pierre-Luc Rigaux
>         Attachments: testParameters.html
>
>
> Hello,
> Here is my problem,
> I try to post some parameters in different languages and the output is wrong.
> Here my exemple.
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
> <html>
> 	<head>
> 		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> 		<title>Test Parameters</title>
> 	</head>
> 	<body>
> 	Test Parm
> 		<form action="/test/encoding" method="POST" enctype="application/x-www-form-urlencoded">
> 		
> 			<input type="hidden" name="property/en" value="School"> 
> 			<input type="hidden" name="property/fr" value="École"> 
> 			<input type="hidden" name="property/zh" value="学校">
> 			
> 			<input type="hidden" name="school" value="School"> 
> 			<input type="hidden" name="école" value="École"> 
> 			<input type="hidden" name="学校" value="学校">
> 			
> 		
> 			<button type="submit">Submit</button>
> 		</form>
> 	</body>
> </html>
> Here the HTTP headers
> Response Headers
> Content-Type	text/html; charset=utf-8
> Server	Jetty(6.1.x)
> Transfer-Encoding	chunked
> Proxy-Connection	Keep-alive
> Request Headers
> Host	localhost:8888
> User-Agent	Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
> Accept	text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Language	en-us,en;q=0.5
> Accept-Encoding	gzip,deflate
> Accept-Charset	ISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive	115
> Proxy-Connection	keep-alive
> Referer	http://localhost:8888/client/testParameters.html
> Cookie	sling.formauth=MTQyMTUxODdiYTI5YTI5ZTYzN2IwNmU4M2ZiYjQ2YThiMjZmOWIzYkA0MTI4NzE2MzQ5Nzg0NkBhZG1pbg
> Here the POST
> Parameters application/x-www-form-urlencoded
> property/en	School
> property/fr	École
> property/zh	学校
> school	School
> école	École
> 学校	学校
> Content-Type: application/x-www-form-urlencoded 
> Content-Length: 152 property%2Fen=School&property%2Ffr=%C3%89cole&property%2Fzh=%E5%AD%A6%E6%A0%A1&school=School&%C3%A9cole=%C3%89cole&%E5%AD%A6%E6%A0%A1=%E5%AD%A6%E6%A0%A1
>  
> Here my analysis
> The problem is due to the method org.apache.sling.engine.impl.parameters.ParameterSupport.getRequestParameterMapInternal() that call the  Util.fixEncoding(parameters);
> Before calling that method all the values are OK but after they are encoded in ISO-8859-1. To fix the problem I send an other parameter _charset_=utf-8. But I think that is the wrong way to do it.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.