Uploaded image for project: 'PUBLIC - Liferay Faces'
  1. PUBLIC - Liferay Faces
  2. FACES-3169

ExternalContext.encodeResourceURL(String url) does not permit relative URLs that do not contain ".."

    Details

      Description

      Background

      The StackOverflow Q&A referenced in FACES-3103 (a related issue) describes the following use-case, which contains a resource URL that is relative to the webapp context:

      view.xhtml
      <h:body>
          ...
          <h:graphicImage name="images/logo.png" />
          ...
      </h:body>
      

      It was discovered that the FacesBridge TCK does not contain a test for this use case, and that the Liferay Faces Bridge Reference Implementation does not support it.

      Steps to Reproduce

      1. Remove the content of the <h:body> tag in jsf-applicant-portlet/src/main/webapp/WEB-INF/views/portletViewMode.xhtml.

      2. Insert the following code into the <h:body> tag:

      <h:graphicImage value="resources/example/liferay-logo.png" />
      

      3. Create the following directory:

      mkdir -p src/main/webapp/resources/example
      

      4. Copy the liferay-logo.png resource to the newly created directory:

      cp src/main/webapp/WEB-INF/resources/example/liferay-logo.png src/main/webapp/resources/example
      

      5. Deploy the jsf-applicant-portlet to Pluto

      6. Visit the following URL:
      http://localhost:9080/pluto/portal/jsf-applicant

      Expected Results

      The Liferay logo is displayed.

      Actual Results

      The Liferay logo is not displayed and the following error appears in the server log:

      java.lang.IllegalArgumentException: only absolute URLs or full path URIs are allowed
      at org.apache.pluto.container.impl.PortletResponseImpl.encodeURL(PortletResponseImpl.java:152)
      at javax.portlet.filter.PortletResponseWrapper.encodeURL(PortletResponseWrapper.java:79)
      at com.liferay.faces.bridge.internal.BaseURLEncodedImpl.toString(BaseURLEncodedImpl.java:40)
      at com.liferay.faces.bridge.internal.BridgeURLBase.toString(BridgeURLBase.java:265)
      at com.liferay.faces.bridge.internal.BridgeURLResourceImpl.toBaseURL(BridgeURLResourceImpl.java:245)
      at com.liferay.faces.bridge.internal.BridgeURLBase.toString(BridgeURLBase.java:243)
      at com.liferay.faces.bridge.context.internal.ExternalContextImpl.encodeResourceURL(ExternalContextImpl.java:244)
      at com.sun.faces.renderkit.RenderKitUtils.getImageSource(RenderKitUtils.java:1408)
      at com.sun.faces.renderkit.html_basic.ImageRenderer.encodeEnd(ImageRenderer.java:96)
      at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:920)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1863)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      at javax.faces.component.UIComponent.encodeAll(UIComponent.java:1859)
      at com.sun.faces.application.view.FaceletViewHandlingStrategy.renderView(FaceletViewHandlingStrategy.java:458)
      at javax.faces.view.ViewDeclarationLanguageWrapper.renderView(ViewDeclarationLanguageWrapper.java:146)
      at com.sun.faces.application.view.MultiViewHandler.renderView(MultiViewHandler.java:134)
      at com.liferay.faces.bridge.application.internal.ViewHandlerCompatImpl.renderView(ViewHandlerCompatImpl.java:95)
      at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:120)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:219)
      at com.liferay.faces.bridge.internal.BridgePhaseHeaderRenderCommon.executeRender(BridgePhaseHeaderRenderCommon.java:206)
      at com.liferay.faces.bridge.internal.BridgePhaseRenderCompatImpl.execute(BridgePhaseRenderCompatImpl.java:67)
      at com.liferay.faces.bridge.internal.BridgePhaseRenderImpl.execute(BridgePhaseRenderImpl.java:57)
      at com.liferay.faces.bridge.internal.BridgeImpl.doFacesRequest(BridgeImpl.java:161)
      at javax.portlet.faces.GenericFacesPortlet.doView(GenericFacesPortlet.java:753)
      at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:348)
      at javax.portlet.faces.GenericFacesPortlet.doDispatch(GenericFacesPortlet.java:669)
      at javax.portlet.GenericPortlet.render(GenericPortlet.java:253)
      at org.apache.pluto.driver.services.container.FilterChainImpl.doFilter(FilterChainImpl.java:163)

        Attachments

          Activity

            People

            Assignee:
            neil.griffin Neil Griffin
            Reporter:
            neil.griffin Neil Griffin
            Participants of an Issue:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Packages

                Version Package
                bridge-impl-2.1.0
                bridge-impl-3.1.0
                bridge-impl-4.1.0