javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2168

ScriptRenderer uses + instead of & to append query string

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.1
    • Fix Version/s: 2.1.20, 2.2.0-m10
    • Component/s: None
    • Labels:
      None
    • Environment:

      Mojarra 2.1.2

      Description

      http://java.net/jira/browse/JAVASERVERFACES-1212

      The fix was wrong. It's using + instead of & to append the query string. This causes the scripts actually not being found (404 error).

      Proposed fix for ScriptRenderer#encodeEnd(), starting at line 113:

      if (query != null) {
          resourceSrc = resourceSrc +
                  ((resourceSrc.indexOf("?") > -1) ? "&amp;" : "?") + // <--- Use &amp; instead of +
                  query;
      }
      
      

        Activity

        Hide
        balusc added a comment -

        Will this ever be fixed or not? As of now only

        <h:outputScript name="script.js?v=1" />
        

        will generate the correct URL

        <script type="text/javascript" src="/playground/javax.faces.resource/script.js.xhtml?v=1"></script>
        

        but with the library

        <h:outputScript library="some" name="script.js?v=1" />
        

        will generate the wrong URL, resulting in a 404

        <script type="text/javascript" src="/playground/javax.faces.resource/script.js.xhtml?ln=some+v=1"></script>
        

        It's a rather simple fix with rather big importance.

        Show
        balusc added a comment - Will this ever be fixed or not? As of now only <h:outputScript name= "script.js?v=1" /> will generate the correct URL <script type= "text/javascript" src= "/playground/javax.faces.resource/script.js.xhtml?v=1" ></script> but with the library <h:outputScript library= "some" name= "script.js?v=1" /> will generate the wrong URL, resulting in a 404 <script type= "text/javascript" src= "/playground/javax.faces.resource/script.js.xhtml?ln=some+v=1" ></script> It's a rather simple fix with rather big importance.
        Hide
        balusc added a comment -

        Note that the name with query string doesn't work at all for h:outputStylesheet

        <h:outputStylesheet name="style.css?v=1" />
        

        The above results in a RES_NOT_FOUND.

        Show
        balusc added a comment - Note that the name with query string doesn't work at all for h:outputStylesheet <h:outputStylesheet name= "style.css?v=1" /> The above results in a RES_NOT_FOUND .
        Hide
        Manfred Riem added a comment -

        Can you verify if this is still an issue on the latest 2.1 release?

        Show
        Manfred Riem added a comment - Can you verify if this is still an issue on the latest 2.1 release?
        Hide
        balusc added a comment -

        Yes, it is. The source code has also not been changed. In Mojarra 2.1.17, the bug is still visible in the source code, at exactly the same linenumber as in the initial report.

        Show
        balusc added a comment - Yes, it is. The source code has also not been changed. In Mojarra 2.1.17, the bug is still visible in the source code, at exactly the same linenumber as in the initial report.
        Hide
        rogerk added a comment -

        Committed to MOJARRA_2_1X_ROLLING:
        Sending jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/ScriptRenderer.java
        Adding test/agnostic/renderKit/basic/src/main/webapp/issue2168.xhtml
        Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary
        Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary/script.js
        Adding test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue2168IT.java
        Transmitting file data ....
        Committed revision 11626.

        Committed to trunk:
        Sending jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/ScriptRenderer.java
        Adding test/agnostic/renderKit/basic/src/main/webapp/issue2168.xhtml
        Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary
        Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary/script.js
        Adding test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue2168IT.java
        Transmitting file data ....
        Committed revision 11627.

        Show
        rogerk added a comment - Committed to MOJARRA_2_1X_ROLLING: Sending jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/ScriptRenderer.java Adding test/agnostic/renderKit/basic/src/main/webapp/issue2168.xhtml Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary/script.js Adding test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue2168IT.java Transmitting file data .... Committed revision 11626. Committed to trunk: Sending jsf-ri/src/main/java/com/sun/faces/renderkit/html_basic/ScriptRenderer.java Adding test/agnostic/renderKit/basic/src/main/webapp/issue2168.xhtml Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary Adding test/agnostic/renderKit/basic/src/main/webapp/resources/alibrary/script.js Adding test/agnostic/renderKit/basic/src/test/java/com/sun/faces/test/agnostic/renderKit/basic/Issue2168IT.java Transmitting file data .... Committed revision 11627.
        Hide
        rogerk added a comment -

        Committed.

        Show
        rogerk added a comment - Committed.

          People

          • Assignee:
            rogerk
            Reporter:
            balusc
          • Votes:
            1 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: