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 2008/09/29 08:26:45 UTC

[jira] Created: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

DefaultSlingScript unconditionally sets the response character encoding
-----------------------------------------------------------------------

                 Key: SLING-679
                 URL: https://issues.apache.org/jira/browse/SLING-679
             Project: Sling
          Issue Type: Bug
          Components: Scripting
    Affects Versions: Scripting Core 2.0.2
            Reporter: Felix Meschberger
            Assignee: Felix Meschberger
             Fix For: Scripting Core 2.0.4


The DefaultSlingScript.service method, which is called by the Sling runtime to execute a script to handle a request, sets the response content type and character encoding. While the content type is only set if it can be defaulted throught the request (SlingHttpServletRequest.getResponseContentType()) the charatcer encoding is unconditionally set to UTF-8.

This causes such interesting content type headers as "image/png; charset=UTF-8", which is not technically wrong, but certainly strange.

It would be more correct to only set the default character encoding if the default content type as retrieved from the request is a text content type, e.g. text/plain, text/html, text/x-whatever.

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


Re: [jira] Commented: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Sep 29, 2008 at 10:20 AM, Felix Meschberger <fm...@gmail.com> wrote:
> Bertrand Delacretaz schrieb:
>> ...Did you consider the application/xml content type?...

> ...I think especially for application/ types, it is the application's
> responsibility to set the correct encoding. In the case of XML, the
> encoding should be set by the XML generator anyway....

Ok, fair enough.

Note that http://www.rfc-editor.org/rfc/rfc3023.txt says the charset
should be present for application/xml [1], so if we have servlets or
scripts that generate XML they should call
response.setCharacterEncoding(...).

-Bertrand

[1] "Although listed as an optional parameter, the use of the charset
parameter is STRONGLY RECOMMENDED, since this information can be
used by XML processors to determine authoritatively the charset of
the XML MIME entity.  The charset parameter can also be used to
provide protocol-specific operations, such as charset-based
content negotiation in HTTP."

Re: [jira] Commented: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Bertrand,

Bertrand Delacretaz schrieb:
> On Mon, Sep 29, 2008 at 8:30 AM, Felix Meschberger (JIRA)
> <ji...@apache.org> wrote:
>> ...Changes in Rev. 699995:
>>
>> * Only set the default character set if the content type is a text/ content type...
> 
> Did you consider the application/xml content type?
> 
> I *think* the response encoding header is not needed in this case, but
> I'm not certain.

No, I did not consider. But I think, in general only the text/ types
benefit of the character encoding default. If any other content type
needs an explicit charcater encoding, the respective script should set it.

I think especially for application/ types, it is the application's
responsibility to set the correct encoding. In the case of XML, the
encoding should be set by the XML generator anyway.

Regards
Felix

Re: [jira] Commented: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

Posted by Bertrand Delacretaz <bd...@apache.org>.
On Mon, Sep 29, 2008 at 8:30 AM, Felix Meschberger (JIRA)
<ji...@apache.org> wrote:
> ...Changes in Rev. 699995:
>
> * Only set the default character set if the content type is a text/ content type...

Did you consider the application/xml content type?

I *think* the response encoding header is not needed in this case, but
I'm not certain.

-Bertrand

[jira] Closed: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/SLING-679?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger closed SLING-679.
-----------------------------------

    Resolution: Fixed

Content type and encoding is properly set now. Therefore closing this issue.

> DefaultSlingScript unconditionally sets the response character encoding
> -----------------------------------------------------------------------
>
>                 Key: SLING-679
>                 URL: https://issues.apache.org/jira/browse/SLING-679
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>    Affects Versions: Scripting Core 2.0.2
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: Scripting Core 2.0.4
>
>
> The DefaultSlingScript.service method, which is called by the Sling runtime to execute a script to handle a request, sets the response content type and character encoding. While the content type is only set if it can be defaulted throught the request (SlingHttpServletRequest.getResponseContentType()) the charatcer encoding is unconditionally set to UTF-8.
> This causes such interesting content type headers as "image/png; charset=UTF-8", which is not technically wrong, but certainly strange.
> It would be more correct to only set the default character encoding if the default content type as retrieved from the request is a text content type, e.g. text/plain, text/html, text/x-whatever.

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


[jira] Commented: (SLING-679) DefaultSlingScript unconditionally sets the response character encoding

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/SLING-679?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12635299#action_12635299 ] 

Felix Meschberger commented on SLING-679:
-----------------------------------------

Changes in Rev. 699995:

* Only set the default character set if the content type is a text/ content type
* Do not write a warn message to the log (debug is ok) if the request cannot provide a default content type

> DefaultSlingScript unconditionally sets the response character encoding
> -----------------------------------------------------------------------
>
>                 Key: SLING-679
>                 URL: https://issues.apache.org/jira/browse/SLING-679
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>    Affects Versions: Scripting Core 2.0.2
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: Scripting Core 2.0.4
>
>
> The DefaultSlingScript.service method, which is called by the Sling runtime to execute a script to handle a request, sets the response content type and character encoding. While the content type is only set if it can be defaulted throught the request (SlingHttpServletRequest.getResponseContentType()) the charatcer encoding is unconditionally set to UTF-8.
> This causes such interesting content type headers as "image/png; charset=UTF-8", which is not technically wrong, but certainly strange.
> It would be more correct to only set the default character encoding if the default content type as retrieved from the request is a text content type, e.g. text/plain, text/html, text/x-whatever.

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