You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Markus Joschko <ma...@gmail.com> on 2011/03/10 18:42:15 UTC

Charset trouble

I have some trouble doing some "custom parameter extension" in a filter.
The filter is executed before the sling servlet. It wraps the current
request and copies the original request parameters to a new map where
additional/computed parameters are added as well.
The modified request (+ parameters) is then passed down to the filter
chain->sling.

That seemed to work fine until I started to care about the encoding.
It turns out, that the original request parameters are returned as
UTF-8 strings to my code when I copy them.
So in my wrapped request I have a request parameter map that contains
UTF-8 strings. But Sling expects ISO-8859-1 strings.

That means I only see garbage on my result page. I can circumvent this
by converting every parameter from the original request to ISO-8859-1
before putting it into my wrapper request parameter map.
However given all the code in sling to properly encode request
parameters I wonder if that is not a bit naive?

Any thoughts?

Thanks,
 Markus

Re: Charset trouble

Posted by Markus Joschko <ma...@gmail.com>.
> pass
> _charset_=utf-8

I've done that. Sling uses that information in a second pass. It
firsts read the information as ISO-8859-1 and then reencodes it with
the characterset specified in the charset (UTF-8)
Howver it initially expects ISO-8859-1 in every case.


>
> On Thu, Mar 10, 2011 at 12:42 PM, Markus Joschko
> <ma...@gmail.com>wrote:
>
>> I have some trouble doing some "custom parameter extension" in a filter.
>> The filter is executed before the sling servlet. It wraps the current
>> request and copies the original request parameters to a new map where
>> additional/computed parameters are added as well.
>> The modified request (+ parameters) is then passed down to the filter
>> chain->sling.
>>
>> That seemed to work fine until I started to care about the encoding.
>> It turns out, that the original request parameters are returned as
>> UTF-8 strings to my code when I copy them.
>> So in my wrapped request I have a request parameter map that contains
>> UTF-8 strings. But Sling expects ISO-8859-1 strings.
>>
>> That means I only see garbage on my result page. I can circumvent this
>> by converting every parameter from the original request to ISO-8859-1
>> before putting it into my wrapper request parameter map.
>> However given all the code in sling to properly encode request
>> parameters I wonder if that is not a bit naive?
>>
>> Any thoughts?
>>
>> Thanks,
>>  Markus
>>
>

Re: Charset trouble

Posted by sam lee <sk...@gmail.com>.
pass
_charset_=utf-8

On Thu, Mar 10, 2011 at 12:42 PM, Markus Joschko
<ma...@gmail.com>wrote:

> I have some trouble doing some "custom parameter extension" in a filter.
> The filter is executed before the sling servlet. It wraps the current
> request and copies the original request parameters to a new map where
> additional/computed parameters are added as well.
> The modified request (+ parameters) is then passed down to the filter
> chain->sling.
>
> That seemed to work fine until I started to care about the encoding.
> It turns out, that the original request parameters are returned as
> UTF-8 strings to my code when I copy them.
> So in my wrapped request I have a request parameter map that contains
> UTF-8 strings. But Sling expects ISO-8859-1 strings.
>
> That means I only see garbage on my result page. I can circumvent this
> by converting every parameter from the original request to ISO-8859-1
> before putting it into my wrapper request parameter map.
> However given all the code in sling to properly encode request
> parameters I wonder if that is not a bit naive?
>
> Any thoughts?
>
> Thanks,
>  Markus
>