Wrong string encoding in JavaScriptPackageResource
--------------------------------------------------

                 Key: WICKET-4460
                 URL: https://issues.apache.org/jira/browse/WICKET-4460
             Project: Wicket
          Issue Type: Bug
          Components: wicket
    Affects Versions: 1.5.5
         Environment: Wicket 1.5.5, Jetty 7.6.2, Windows
            Reporter: Jonas
            Priority: Minor


org.apache.wicket.request.resource.JavaScriptPackageResource.processResponse(Attributes,
 byte[])
transforms javascript using an IJavaScriptCompressor if configured - which is 
the case by default in deployment mode, but not in development mode.
The problem is that the code uses UTF-8 encoding when creating the String from 
bytes, but when converting the result String of IJavaScriptCompressor back to 
bytes, the platform's default encoding is used (e.g. Cp1252 on Windows).
I propose to at least use the same character encoding while converting from/to 
bytes:

something like (JavaScriptPackageResource line 59 and following):

                        try
                        {
                                String nonCompressed = new 
String(processedResponse, "UTF-8");
                                return 
compressor.compress(nonCompressed).getBytes("UTF-8");
                        }
                        catch (Exception e)
                        {
                                log.error("Error while filtering content", e);
                                return processedResponse;
                        }


Of course it would be even better not to make any assumtions about the encoding 
of the .js file, but I'm not sure how one could determine that.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to