Hi guys,

I think there is a bug in sling's parameter encoding handling. It even fails at simple sample. Like this:

<form action="/contents/hello" method="post">
        <input name="test" value="测试"/>
        <input type="hidden" name="_charset_" value="utf-8" />
</form>

The cause of this problem is simple. When Sling get the request from osgi's http service, sling wrap the request in to its request, and if it can't guess the encoding of the request, it will use ISO-8859-1 as default.

Then it will use _charset_ parameter to fix it(if has).

But, there is something wrong when fixing the encoding, in ContainerRequestParameter's setEncoding method it decode its value first using the default charset ISO-8859-1(which is set as default), so "测试" becomes "??".

My solution is change ContainerRequestParameter's setEncoding method, make it don't decode the string, only get the byte of its value and encode it.

Is there a better way to fix this bug?
-----
Jack



Reply via email to