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

PortletV3Demo DependencyPortlet does not encode the exception message

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0.1
    • 3.1.0
    • demo portlets
    • None

    Description

      The PortletV3Demo has the following try/catch block:

      DependencyPortlet.java
               try {
                  resp.addDependency("Invalid", "attempt", "1.1.1", dep);
                  xmap.put(disp, "No exception");
               } catch (Exception e) {
                  xmap.put(disp, e.toString());
               }
      

      The call to e.toString will put the textual message of the exception into the map, which eventually gets rendered inside the portlet:

      dependencyDialog.jsp
      <h3>Tests for Bad Dependency Strings:</h3>
         <c:forEach items="${xmap}" var="entry">
            <p>
            String: ${entry.key }<br>
            Exception: ${entry.value }
            </p>   
         </c:forEach>
      

      The problem is that the e.toString textual message might contain special HTML characters such as the less-than (<) character (as is the case with Liferay Portal) which needs to be encoded. Otherwise the <script> that follows will not become part of the DOM:

      <script>
      $(document).ready(function(){
          $("#<portlet:namespace/>button").click(function(){
              var txt = "jQuery version: " + $().jquery;
              $("#<portlet:namespace/>fadeText").text(txt);
              $("#<portlet:namespace/>fadeBox").fadeIn(3000);
          });
      });
      </script>
      

      Attachments

        Activity

          People

            ngriffin7a Neil Griffin (Inactive)
            ngriffin7a Neil Griffin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: