Uploaded image for project: 'Pluto'
  1. Pluto
  2. PLUTO-85

renderResponse.getNamespace() returns invalid Javascript name

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: unspecified
    • Fix Version/s: unspecified
    • Component/s: portlet container
    • Labels:
      None
    • Environment:
      Cocoon-2.1.5.1 portal

      Description

      Use of renderResponse.getNamespace() method is primary for prefixing names of script variables and functions in portlets.

      In Cocoon-2.1.5.1 portal environment renderRequest.getNamespace() returns i.e. 'Helloworld-1' and Pluto consequently constructs namespace as 'Pluto_Helloworld-1_'. Such a name is not valid name for Javascript function or variable.

      Patch that translates all '-' to '_' in returning namespace is attached.

      1. TIMESTAMP_20041116.patch_1.diff
        1 kB
        Michal Durdina
      2. RenderResponseImpl.diff.txt
        0.8 kB
        @deprecated ZHENG Zhong

        Activity

        Hide
        durdina Michal Durdina added a comment -

        patch for RenderResponseImpl.java

        Show
        durdina Michal Durdina added a comment - patch for RenderResponseImpl.java
        Hide
        nlothian Nick Lothian added a comment -

        Patch applied

        Show
        nlothian Nick Lothian added a comment - Patch applied
        Hide
        wytten Dale Wyttenbach added a comment -

        The fix included in 1.0.1-rc2 is not sufficent. The code comment included with the fix is what should be done:

        // correct all chars in the ns + name that are not valid for qualified names

        However, the fix provided does not correct all chars that are not valid, it only corrects the hyphens, and lets other invalid chars like '.' appear in the namespace. If the String returned by this method is subsequently used to construct the name of a JavaScript function, that JavaScript will not parse correctly.

        You might try using the static isJavaIdentifierPart method in java.lang.Character to validate every character in the constructed namespace.

        Show
        wytten Dale Wyttenbach added a comment - The fix included in 1.0.1-rc2 is not sufficent. The code comment included with the fix is what should be done: // correct all chars in the ns + name that are not valid for qualified names However, the fix provided does not correct all chars that are not valid, it only corrects the hyphens, and lets other invalid chars like '.' appear in the namespace. If the String returned by this method is subsequently used to construct the name of a JavaScript function, that JavaScript will not parse correctly. You might try using the static isJavaIdentifierPart method in java.lang.Character to validate every character in the constructed namespace.
        Hide
        adouma Ate Douma added a comment -

        I agree with Dale on this one: this issue isn't Fixed yet and not (fully) conforming the Portlet API yet.

        The API javadoc for RenderResponse.getNamespace() says:
        "The value returned by this method should be prefixed or appended to elements, such as JavaScript variables or function names, to ensure they are unique in the context of the portal page."

        So, support for at least JavaScript variable or function names conformance should be provided I think.

        I therefor kindly ask if this issue can be reopened.

        For Jetspeed-2 a similar issue was created:
        http://issues.apache.org/jira/browse/JS2-217

        I'm going to refer that issue back to this one, hoping Pluto will fix this for us

        Regards, Ate

        Show
        adouma Ate Douma added a comment - I agree with Dale on this one: this issue isn't Fixed yet and not (fully) conforming the Portlet API yet. The API javadoc for RenderResponse.getNamespace() says: "The value returned by this method should be prefixed or appended to elements, such as JavaScript variables or function names, to ensure they are unique in the context of the portal page." So, support for at least JavaScript variable or function names conformance should be provided I think. I therefor kindly ask if this issue can be reopened. For Jetspeed-2 a similar issue was created: http://issues.apache.org/jira/browse/JS2-217 I'm going to refer that issue back to this one, hoping Pluto will fix this for us Regards, Ate
        Hide
        cdoremus Craig Doremus added a comment -

        Reopened per comments from Dale and Ate.

        Show
        cdoremus Craig Doremus added a comment - Reopened per comments from Dale and Ate.
        Hide
        heavyz @deprecated ZHENG Zhong added a comment -

        The patch to correct the namespace problem.

        Show
        heavyz @deprecated ZHENG Zhong added a comment - The patch to correct the namespace problem.
        Hide
        heavyz @deprecated ZHENG Zhong added a comment -

        I've made a patch to fix the RenderResponse's namespace problem in the 1.0.1-rc3 release. Characters in the namespace are validated by Character.isJavaIdentifierPart() method, and all invalid characters are replaced by '_'.

        Regards.
        ZHENG Zhong

        Show
        heavyz @deprecated ZHENG Zhong added a comment - I've made a patch to fix the RenderResponse's namespace problem in the 1.0.1-rc3 release. Characters in the namespace are validated by Character.isJavaIdentifierPart() method, and all invalid characters are replaced by '_'. Regards. ZHENG Zhong
        Hide
        cdoremus Craig Doremus added a comment -

        In patched RenderResponseImpl with Zhong Zheng's patch in SVN revision 220190

        Show
        cdoremus Craig Doremus added a comment - In patched RenderResponseImpl with Zhong Zheng's patch in SVN revision 220190

          People

          • Assignee:
            Unassigned
            Reporter:
            durdina Michal Durdina
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development