Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-25836

Rhino is not decoding unicode or hex escape sequences in JavaScript

    Details

      Description

      Steps to reproduce:

      1. Navigate to Control Panel > Server Administration > Script
      2. Paste execute the script out.println("\u0073" == "s");
      3. Open Chrome or Safari JavaScript console
      4. Run the same script

      Expected: results from 2 and 4 should be the same (both true).
      Actual: 2 is false and 4 is true

      This is only one symptom of the problem (LPS-25044 is another symptom). The problem is that our Rhino environment is not decoding unicode of hex escape sequences. This can be easily seen by executing the code "\u0073" using liferay-rhino.jar. It will print \u0073 whereas with the rhino.jar downloaded from mozilla it prints s (even though both are the same version of Rhino).

      This is happening because we use YUI Compressor which uses a modified version of Rhino which does not decode escape sequences. The YUI Compressor version of Rhino is overwriting the normal version for us.

      In fixing this, I've done the following:

      1. Repackaged YUI Compressor so that it's version of Rhino is namespaced at com.yahoo.platform.yui and will not conflict with other versions.
      2. Repackaging is now done with Jar Jar Links (http://code.google.com/p/jarjar) which works on the binary yuicompressor.jar instead of find and replace in source and then compiling. This is much simpler and means we only need to include the binary jar in /tools instead of the source zip. Another advantage is that we don't need to compile it (compilation was broken anyway because it could no longer download one of its dependencies because the version we use is slightly older).
      3. To upgrade YUI Compressor replace the jar in /tools with the new one, run the build-yuicompressor target of portal-impl/build.xml (if the new tools jar has a different name than the old one, update the name in the build.xml first). The new jar will be generated at /lib/portal/liferay-yuicompressor.jar.new. Delete the other one and remove the .new extension.
      4. Used vanilla Rhino instead of namespacing it to com.liferay. This will make it much easier to upgrade: just overwrite the jar with the new one in /lib/portal. The reason we were namespacing it to com.liferay was so that it wouldn't conflict with the rhino.jar that WebLogic includes (LPS-3169), but the proper fix for this is to modify weblogic.xml to tell it we will use our own Rhino classes.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Days since last comment:
                  6 years, 31 weeks, 4 days ago

                  Packages

                  Version Package
                  6.0.X EE
                  6.1.20 EE GA2
                  --Sprint 11/12
                  6.2.0 CE M2