Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4460

Wrong string encoding in JavaScriptPackageResource

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.5.5
    • 1.5.6, 6.0.0-beta1
    • wicket
    • None
    • Wicket 1.5.5, Jetty 7.6.2, Windows

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              mgrigorov Martin Tzvetanov Grigorov
              jonas Jonas
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: