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

processScript in Wicket.Head.Contributor doesn't remove CDATA - eval fails in IE

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.4, 1.5.5
    • 1.5.6, 6.0.0-beta1
    • wicket
    • None
    • Windows 7 64-bit
      Firefox 10 (is OK) and IE 8,9 (they fail)
      Wicket 1.5.4 and 1.5.5 tested
      Jetty

    Description

      There's incosistency between org.apache.wicket.util.string.JavaScriptUtils and wicket-ajax.js
      Even though the source is marked with comment

      • Script open tag. If this tag is changed, also update Wicket.Head.Contributor.processScript()
      • function from wicket-ajax.js

      In JavaScriptUtils there are:
      public final static String SCRIPT_CONTENT_PREFIX = "\n/<![CDATA[/\n";
      public final static String SCRIPT_CONTENT_SUFFIX = "\n/]]>/\n";

      in wicket-ajax.js (line 1742 in 1.5.5 version) there are:
      // get rid of prefix and suffix, they are not eval-d correctly
      text = text.replace(/^<!-\/*><![CDATA[\/*><!-*\//, "");
      text = text.replace(/\/*-->]]>*\/$/, "");

      As you can see the sequences in java and javascript DO NOT MATCH! There are missing new lines in JS and there are extra HTML comments <!-- --> that aren't added by the Java code.
      The result is, that these extra lines aren't removed and IE fails to eval such a javascript. I could fix this issue by editing the wicket-ajax.js like this:
      text = text.replace(/^\n\/*<![CDATA[*\/\n/, "");
      text = text.replace(/\n\/*]]>*\/\n$/, "");

      But we need it fixed officially, because we use gradle for Wicket dependency.

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            davesman David Rain
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: