javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-1867

RenderKitUtils.getImageSource does not call encodeResourceURL

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: 2.1_gf31_m7
    • Component/s: resources
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      1,867

      Description

      If resName is given, getImageSource does not call
      ExternalContext.encodeResourceURL - if name is not there, encodeResourceURL is
      called.

      encodeResourceURL must be called in either case!

      public static String getImageSource(FacesContext context, UIComponent
      component, String attrName) {

      String resName = (String) component.getAttributes().get("name");
      if (resName != null) {
      String libName = (String) component.getAttributes().get("library");
      ResourceHandler handler = context.getApplication().getResourceHandler();
      Resource res = handler.createResource(resName, libName);
      if (res == null) {
      if (context.isProjectStage(ProjectStage.Development))

      { String msg = "Unable to find resource " + resName; context.addMessage(component.getClientId(context), new FacesMessage(FacesMessage.SEVERITY_ERROR, msg, msg)); }

      return "RES_NOT_FOUND";
      } else

      { return res.getRequestPath(); }

      } else {

      String value = (String) component.getAttributes().get(attrName);
      if (value == null || value.length() == 0)

      { return ""; }

      if (value.contains(ResourceHandler.RESOURCE_IDENTIFIER))

      { return value; }

      else

      { value = context.getApplication().getViewHandler(). getResourceURL(context, value); return (context.getExternalContext().encodeResourceURL(value)); }

      }

      }

      1. RenderKitUtils-1867.patch
        0.6 kB
        Hanspeter Duennenberger

        Activity

        Hide
        Ed Burns added a comment -

        Thanks for posting this. I'll get on it right away.

        Show
        Ed Burns added a comment - Thanks for posting this. I'll get on it right away.
        Hide
        Hanspeter Duennenberger added a comment -

        Created an attachment (id=1336)
        RenderKitUtils.patch

        Show
        Hanspeter Duennenberger added a comment - Created an attachment (id=1336) RenderKitUtils.patch
        Hide
        Ed Burns added a comment -

        Assign to Rogerk

        Show
        Ed Burns added a comment - Assign to Rogerk
        Hide
        rogerk added a comment -

        Thanks for the patch.

        Sending jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java
        Transmitting file data .
        Committed revision 8741.

        Show
        rogerk added a comment - Thanks for the patch. Sending jsf-ri/src/main/java/com/sun/faces/renderkit/RenderKitUtils.java Transmitting file data . Committed revision 8741.
        Hide
        Manfred Riem added a comment -

        Closing issue out

        Show
        Manfred Riem added a comment - Closing issue out

          People

          • Assignee:
            rogerk
            Reporter:
            Hanspeter Duennenberger
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: