ICEfaces
  1. ICEfaces
  2. ICE-3416

The content of <script> tags are being wrapped by <span> tags.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.1
    • Fix Version/s: 1.7.2
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      all

      Description

      Putting a script into an ICEfaces page

      <script type="text/javascript">
      alert("Beep");
      </script>

      Currently gets rendered out as:

      <script type="text/javascript">
      <span id = "_components_buttonsAndLinks_WAR_componentshowcase_INSTANCE_2nr4_ :j_id4">alert("Beep");</span>
      </script>

      Wrapping the contents in a <span> causes the code to, obviously, not execute. The problem surfaces in the 1.7 branch on revision 17279.

      The problem according to Mark is:

      With JSF 1.1, generated ids are of the form _idNUMBER, whereas with JSF 1.2, they are j_id_NUMBER.

      In TextRenderer, part of the logic to have a span is:

      if (idNotNull(uiComponent) && !uiComponent.getId().startsWith("_")) {
        return true;
      }

      Which means, if the component has an id, and it was specifically given, and not generated, than use a span. But the heuristic for it not being generated was for JSF 1.1, not JSF 1.2. It worked out, because we had put in place our own generated id scheme, for plain text, that was _iceIDNUMBER, which started with the underscore. Changing that to use the JSF 1.2 generated id broke things.

      The solution is not to back out the generated id fix. Instead we could update TextRenderer to use a better heuristic for having a specified id. Or we could just set a flag on OutputText, so it will just not put spans around plain text. There's the little question of when <ice:outputText> is used (and not plain text), and no id was given, so it's generated, what we're supposed to do, use a span or not.

        Issue Links

          Activity

          Deryk Sinotte created issue -
          Deryk Sinotte made changes -
          Field Original Value New Value
          Component/s Components [ 10012 ]
          Fix Version/s 1.7.2 [ 10130 ]
          Affects Version/s 1.7.1 [ 10122 ]
          Assignee Mark Collette [ mark.collette ]
          Deryk Sinotte made changes -
          Link This issue blocks ICE-3315 [ ICE-3315 ]
          Hide
          Christophe Taverne added a comment -

          Hi,

          on the current svn, The content of <style> tags are being wrapped by <span> tags too.

          regards,

          Show
          Christophe Taverne added a comment - Hi, on the current svn, The content of <style> tags are being wrapped by <span> tags too. regards,
          Ken Fyten made changes -
          Assignee Priority P3
          Hide
          Christophe Taverne added a comment -

          Hi,

          In the same way, title tag has the same problem.
          Please see: http://jira.icefaces.org/browse/ICE-3370

          regards,

          Show
          Christophe Taverne added a comment - Hi, In the same way, title tag has the same problem. Please see: http://jira.icefaces.org/browse/ICE-3370 regards,
          Hide
          Ken Fyten added a comment -

          Note from Deryk:

          This has some serious consequences for apps that have inline <script> or <style> tags embedded in their existing pages. We don't tend to do this so a lot of our apps won't show any ill effects in testing but I think it could impact a lot of customers. It stops incline scripts from being executed and inline styles from being applied.

          Show
          Ken Fyten added a comment - Note from Deryk: This has some serious consequences for apps that have inline <script> or <style> tags embedded in their existing pages. We don't tend to do this so a lot of our apps won't show any ill effects in testing but I think it could impact a lot of customers. It stops incline scripts from being executed and inline styles from being applied.
          Ken Fyten made changes -
          Assignee Priority P3 P1
          Hide
          Ken Fyten added a comment -

          This is specific to JSPs.

          Currently, the outputText renderer tries to determine if it should wrap it's contents in a SPAN tag using a cruddy fuzzy bit of logic. Instead, we should just add a new attribute to the ice:outputText to switch the SPAN wrapping on/off, called 'nospan', default is false. The JSP parser will then assign this attribute the correct value depending on whether the component is being used to render an HTML tag such as TITLE, SCRIPT, STYLE, etc. The correct value in this case, being 'nospan=true'.

          Show
          Ken Fyten added a comment - This is specific to JSPs. Currently, the outputText renderer tries to determine if it should wrap it's contents in a SPAN tag using a cruddy fuzzy bit of logic. Instead, we should just add a new attribute to the ice:outputText to switch the SPAN wrapping on/off, called 'nospan', default is false. The JSP parser will then assign this attribute the correct value depending on whether the component is being used to render an HTML tag such as TITLE, SCRIPT, STYLE, etc. The correct value in this case, being 'nospan=true'.
          Ken Fyten made changes -
          Assignee Mark Collette [ mark.collette ] Yip Ng [ yip.ng ]
          Ken Fyten made changes -
          Link This issue depends on ICE-1931 [ ICE-1931 ]
          Ken Fyten made changes -
          Fix Version/s 1.7.2RC1 [ 10140 ]
          Fix Version/s 1.7.2 [ 10130 ]
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #17529 Tue Sep 09 14:47:42 MDT 2008 yip.ng ICE-3416
          Changed to not render <span> tags for <script>, <style> and <title> tags.
          Files Changed
          Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/parser/IceOutputTextTag.java
          Repository Revision Date User Message
          ICEsoft Public SVN Repository #17530 Tue Sep 09 14:56:58 MDT 2008 yip.ng ICE-3416
          Changed to not render <span> tags for <script>, <style> and <title> tags.
          Files Changed
          Commit graph MODIFY /icefaces/branches/icefaces-1.7/icefaces/core/src/com/icesoft/faces/webapp/parser/IceOutputTextTag.java
          made changes -
          Attachment screenshot-1.jpg [ 11231 ]
          Hide
          yip.ng added a comment -

          See screenshot-1 for an illustration of the problem. Notice how the texts of the <title>, <style> and <script> tags are surrounded by <span> tags. And the style and script are not being executed.

          Show
          yip.ng added a comment - See screenshot-1 for an illustration of the problem. Notice how the texts of the <title>, <style> and <script> tags are surrounded by <span> tags. And the style and script are not being executed.
          Hide
          yip.ng added a comment -

          Note that you can use either plain text or <ice:outputText> inside a <title> tag or <style> tag. This JIRA case is for when you use plain text.

          A "nospan" attribute has already been added to the <ice:outputText> tag in ICE-1931. So to avoid a span tag in that case, just set "nospan" to true:

          <title><ice:outputText value="ICEfaces Component Suite" nospan="true"/></title>

          Show
          yip.ng added a comment - Note that you can use either plain text or <ice:outputText> inside a <title> tag or <style> tag. This JIRA case is for when you use plain text. A "nospan" attribute has already been added to the <ice:outputText> tag in ICE-1931 . So to avoid a span tag in that case, just set "nospan" to true: <title><ice:outputText value="ICEfaces Component Suite" nospan="true"/></title>
          made changes -
          Attachment screenshot-2.jpg [ 11233 ]
          made changes -
          Attachment screenshot-3.jpg [ 11234 ]
          Hide
          yip.ng added a comment -

          Fixed. See screenshot-2 and screenshot-3.

          Show
          yip.ng added a comment - Fixed. See screenshot-2 and screenshot-3.
          yip.ng made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Ken Fyten made changes -
          Fix Version/s 1.7.2 [ 10130 ]
          Fix Version/s 1.7.2RC1 [ 10140 ]
          Hide
          Joanne Bai added a comment -

          Tested successfully on Branch 1.7 revision #17583
          (Test environment: Tomcat 6 + Firefox 2, IE 6, Opera 9.2)

          Show
          Joanne Bai added a comment - Tested successfully on Branch 1.7 revision #17583 (Test environment: Tomcat 6 + Firefox 2, IE 6, Opera 9.2)
          Ken Fyten made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Assignee Priority P1
          Assignee Yip Ng [ yip.ng ]

            People

            • Assignee:
              Unassigned
              Reporter:
              Deryk Sinotte
            • Votes:
              1 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: