ICEfaces
  1. ICEfaces
  2. ICE-4342

OutputResource filename characters are not correct

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.7.2 SP1
    • Fix Version/s: 1.8.2-RC1, 1.8.2
    • Component/s: ICE-Components
    • Labels:
      None
    • Environment:
      Linux, Windows, Mac OS X & IE, Safari, Firefox & Glassfish v2

      Description

      I have problems with downloading files via OutputResource where filename contains special characters like €, £, ... Also it doesn't work for our national characters like ěščřžýáíéĚŠČŘŽÝÁÉ. Anyway, I was able to manage file upload with these special characters via CharsetFilter (mentioned in the forum post). But I'm not able to download these files with correct file name. I tried lot of things, spent few weeks in forums, but I can't find a way how to download file with special characters in the filename via OutputResource.

      I think it's a bug of OutputResource, because instead of writing filename directly to Content-Disposition, it should encode it somehow first.
      1. fileName with '('.jpg
        76 kB
      2. ScreenHunter_01.jpg
        224 kB
      3. ScreenHunter_02.jpg
        224 kB
      4. ScreenHunter_03.jpg
        220 kB
      5. ScreenHunter_04.jpg
        212 kB
      6. ScreenHunter_05.jpg
        211 kB
      7. ScreenHunter_06.jpg
        219 kB
      8. ScreenHunter_07.jpg
        207 kB
      9. ScreenHunter_08.jpg
        219 kB
      10. ScreenHunter_09.jpg
        214 kB
      11. ScreenHunter_10.jpg
        255 kB

        Activity

        Ken Fyten made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Assignee Priority P3
        Ken Fyten made changes -
        Fix Version/s 1.8.2-RC1 [ 10210 ]
        Ken Fyten made changes -
        Issue Type Bug [ 1 ] Improvement [ 4 ]
        Salesforce Case []
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #19137 Fri Jul 31 11:36:14 MDT 2009 yip.ng ICE-4342
        Fixe bugs that caused download failure of files with special characters in their file names.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/outputresource/OutputResource.java
        yip.ng made changes -
        Status Reopened [ 4 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        yip.ng added a comment -

        Test instructions for QA:

        In the component showcase demo for Download Resources, try the following names as the download file name:

        €£ěščřžýáíéĚŠČŘŽÝÁÉ
        Français+Español
        Testingday_20_5__(a)_200907141213
        The string ü@foo-bar
        foo-%41
        foo-ä
        foo-ä-€

        The popup save file dialog should display the proper file names on both IE and Firefox.

        Also, try serving from Unix and downloading on Windows, and vice versa.

        Show
        yip.ng added a comment - Test instructions for QA: In the component showcase demo for Download Resources, try the following names as the download file name: €£ěščřžýáíéĚŠČŘŽÝÁÉ Français+Español Testingday_20_5__(a)_200907141213 The string ü@foo-bar foo-%41 foo-ä foo-ä-€ The popup save file dialog should display the proper file names on both IE and Firefox. Also, try serving from Unix and downloading on Windows, and vice versa.
        Hide
        yip.ng added a comment -

        Added detection for Opera. Changed encoding method for Firefox and Opera. (Required changes to other parts of OutputResource and ResourceDispatcher as well.)

        New .war file attached.

        Show
        yip.ng added a comment - Added detection for Opera. Changed encoding method for Firefox and Opera. (Required changes to other parts of OutputResource and ResourceDispatcher as well.) New .war file attached.
        yip.ng made changes -
        Attachment c-s-jsp.war [ 11879 ]
        yip.ng made changes -
        Attachment c-s-jsp.war [ 11875 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #19114 Thu Jul 23 16:03:39 MDT 2009 yip.ng ICE-4342
        Fixe bugs that caused download failure of files with special characters in their file names.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/outputresource/OutputResource.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/ResourceDispatcher.java
        Hide
        Robert Vojta added a comment -

        Mistake, second line s/Operate/Opera/, sorry.

        Show
        Robert Vojta added a comment - Mistake, second line s/Operate/Opera/, sorry.
        Hide
        Robert Vojta added a comment -

        Hi Yip, thanks for testing war. I'll test it tomorrow.

        I think it should be good to change behavior for Firefox & Operate to this one ...

        http://greenbytes.de/tech/tc2231/#attwithfn2231utf8

        Content-Disposition: attachment; filename*=UTF-8''foo-a%cc%88.html

        ... my solution for Firefox works because of wrong implementation in FF - probably will be fixed in the future. And I choosed it because I was able to add anything after "filename=" in OutputResource, but I wasn't able to use "attachment; filename*=" (see * before =) with OutputResource without source code modification. And as you're fixing it directly in the source code, it would be nice to have cleaner and more stable approach.

        Show
        Robert Vojta added a comment - Hi Yip, thanks for testing war. I'll test it tomorrow. I think it should be good to change behavior for Firefox & Operate to this one ... http://greenbytes.de/tech/tc2231/#attwithfn2231utf8 Content-Disposition: attachment; filename*=UTF-8''foo-a%cc%88.html ... my solution for Firefox works because of wrong implementation in FF - probably will be fixed in the future. And I choosed it because I was able to add anything after "filename=" in OutputResource, but I wasn't able to use "attachment; filename*=" (see * before =) with OutputResource without source code modification. And as you're fixing it directly in the source code, it would be nice to have cleaner and more stable approach.
        Hide
        yip.ng added a comment -

        See screenshots 08 - 10.

        Added encoding of content disposition file name. This requires browser detection on the server side. Encoding for IE and Firefox is based on suggestion above from Robert Vojta. Other browsers and encoding methods may have to be added later case by case.

        New .war file attached.

        Show
        yip.ng added a comment - See screenshots 08 - 10. Added encoding of content disposition file name. This requires browser detection on the server side. Encoding for IE and Firefox is based on suggestion above from Robert Vojta. Other browsers and encoding methods may have to be added later case by case. New .war file attached.
        yip.ng made changes -
        Attachment c-s-jsp.war [ 11875 ]
        yip.ng made changes -
        Attachment c-s-jsp.war [ 11867 ]
        yip.ng made changes -
        Attachment ScreenHunter_08.jpg [ 11872 ]
        Attachment ScreenHunter_09.jpg [ 11873 ]
        Attachment ScreenHunter_10.jpg [ 11874 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #19107 Wed Jul 22 16:41:34 MDT 2009 yip.ng ICE-4342
        Fixe bugs that caused download failure of files with special characters in their file names.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/outputresource/OutputResource.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/ResourceDispatcher.java
        Hide
        yip.ng added a comment -

        See screenshots 06 and 07.

        Fixed file name display on web page by using Unicode escape sequences in file name in backing bean, i.e., fileName = "€£\u011Bš\u010D\u0159žýáíé\u011AŠ\u010C\u0158ŽÝÁÉ";

        However, in FF, the file name in the save file dialog still doesn't match exactly; in IE, you get an error "... cannot download ... not able to open Internet site ..."

        .war file attached.

        Show
        yip.ng added a comment - See screenshots 06 and 07. Fixed file name display on web page by using Unicode escape sequences in file name in backing bean, i.e., fileName = "€£\u011Bš\u010D\u0159žýáíé\u011AŠ\u010C\u0158ŽÝÁÉ"; However, in FF, the file name in the save file dialog still doesn't match exactly; in IE, you get an error "... cannot download ... not able to open Internet site ..." .war file attached.
        yip.ng made changes -
        Attachment c-s-jsp.war [ 11867 ]
        yip.ng made changes -
        Attachment ScreenHunter_06.jpg [ 11865 ]
        Attachment ScreenHunter_07.jpg [ 11866 ]
        Hide
        Robert Vojta added a comment -

        It would be nice to have some testing war. So, I can test it under our environment. I can cover Firefox, IE, Safari and Opera on Mac, Linux and Windows (where available). I can also test it under different environments - I mean different OS languages, localization, fonts, etc.

        Show
        Robert Vojta added a comment - It would be nice to have some testing war. So, I can test it under our environment. I can cover Firefox, IE, Safari and Opera on Mac, Linux and Windows (where available). I can also test it under different environments - I mean different OS languages, localization, fonts, etc.
        Hide
        Ted Goddard added a comment -

        This filename is working correctly in Safari on the Mac. This indicates that the unicode conversion is correct and difficulties saving certain filenames may actually be browser or operating system dependent problems.

        Yip, can you attach your .war file that allows FileUpload filenames to be tested to this JIRA?

        Show
        Ted Goddard added a comment - This filename is working correctly in Safari on the Mac. This indicates that the unicode conversion is correct and difficulties saving certain filenames may actually be browser or operating system dependent problems. Yip, can you attach your .war file that allows FileUpload filenames to be tested to this JIRA?
        Hide
        yip.ng added a comment - - edited

        Tested using file name €£ěščřžýáíéĚŠČŘŽÝÁÉ. The file name is displayed as €£?š??žýáíé?Š??ŽÝÁÉ on web page and as ¬£a~ýáíé`__}ÝÁÉ on save file dialog. See screenshot 05. (Same on IE.) So some characters are not working. Need to figure out how to fix this.

        Show
        yip.ng added a comment - - edited Tested using file name €£ěščřžýáíéĚŠČŘŽÝÁÉ. The file name is displayed as €£?š??žýáíé?Š??ŽÝÁÉ on web page and as ¬£ a ~ýáíé `__}ÝÁÉ on save file dialog. See screenshot 05. (Same on IE.) So some characters are not working. Need to figure out how to fix this.
        yip.ng made changes -
        Attachment ScreenHunter_05.jpg [ 11862 ]
        yip.ng made changes -
        Resolution Fixed [ 1 ]
        Status Resolved [ 5 ] Reopened [ 4 ]
        Hide
        yip.ng added a comment -

        All test cases already tested on both IE7 and FF3.

        Show
        yip.ng added a comment - All test cases already tested on both IE7 and FF3.
        Hide
        Robert Vojta added a comment -

        Have you tried € or £ or all German umlauts for example? I can see ue and @, which is not enough IMHO. Have you tested it with IE too? I'm asking because what I can see are attached screenshots only.

        Show
        Robert Vojta added a comment - Have you tried € or £ or all German umlauts for example? I can see ue and @, which is not enough IMHO. Have you tested it with IE too? I'm asking because what I can see are attached screenshots only.
        yip.ng made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Fixed [ 1 ]
        Hide
        yip.ng added a comment -

        Fixed. See screenshots 01 to 04.

        Bugs caused by inappropriate URL encoding, URL pattern matching and URI method usage.

        Changed to:

        • use UTF encoding
        • encode space character to %20
        • use Unicode escape sequences for pattern matching
        • use raw path from URI for outputting link
        Show
        yip.ng added a comment - Fixed. See screenshots 01 to 04. Bugs caused by inappropriate URL encoding, URL pattern matching and URI method usage. Changed to: use UTF encoding encode space character to %20 use Unicode escape sequences for pattern matching use raw path from URI for outputting link
        yip.ng made changes -
        Attachment ScreenHunter_04.jpg [ 11859 ]
        yip.ng made changes -
        Attachment ScreenHunter_01.jpg [ 11856 ]
        Attachment ScreenHunter_02.jpg [ 11857 ]
        Attachment ScreenHunter_03.jpg [ 11858 ]
        Repository Revision Date User Message
        ICEsoft Public SVN Repository #19090 Mon Jul 20 14:12:19 MDT 2009 yip.ng ICE-4342
        Fixe bugs that caused download failure of files with special characters in their file names.
        Files Changed
        Commit graph MODIFY /icefaces/trunk/icefaces/component/src/com/icesoft/faces/component/outputresource/OutputResource.java
        Commit graph MODIFY /icefaces/trunk/icefaces/core/src/com/icesoft/faces/webapp/http/core/ResourceDispatcher.java
        yip.ng made changes -
        Attachment ScreenHunter_01.jpg [ 11852 ]
        yip.ng made changes -
        Attachment ScreenHunter_01.jpg [ 11852 ]
        Hide
        yip.ng added a comment -

        Seems it is not just a matter of changing the encoding methods. There is some major misunderstanding (or neglect) in the code about URL encoding and pattern matching. (Not only the processes involved, but also the related classes like URLEncoder, URI, Pattern, etc.)

        Show
        yip.ng added a comment - Seems it is not just a matter of changing the encoding methods. There is some major misunderstanding (or neglect) in the code about URL encoding and pattern matching. (Not only the processes involved, but also the related classes like URLEncoder, URI, Pattern, etc.)
        Hide
        yip.ng added a comment -

        Removed the file quotes in the encoding, but still didn't work for file names with special characters:

        Could not find resource at /component-showcase-trunk/block/resource/Mzc4NDI4NjUw/Testingday_20_5__(a)_200907141213.pdf

        Show
        yip.ng added a comment - Removed the file quotes in the encoding, but still didn't work for file names with special characters: Could not find resource at /component-showcase-trunk/block/resource/Mzc4NDI4NjUw/Testingday_20_5__(a)_200907141213.pdf
        Hide
        yip.ng added a comment -

        Tried using the suggested encoding methods. Got the following exceptions:

        14-Jul-2009 5:37:48 PM com.sun.faces.lifecycle.Phase doPhase
        name = /block/resource/MjAyNjQwNTE1MA==/
        SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /showcase.jspx) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@f77511]
        14-Jul-2009 5:37:48 PM com.icesoft.faces.webapp.http.core.ReceiveSendUpdates service
        SEVERE: Exception occured during rendering on http://localhost:8080/component-showcase-trunk/block/send-receive-updates [/showcase.jspx]
        javax.faces.FacesException: java.lang.IllegalArgumentException
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:128)
        at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
        at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:19)
        at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132)
        at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74)
        at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:28)
        at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24)
        at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160)
        at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:42)
        at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:27)
        at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63)
        at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:62)
        at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:22)
        at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23)
        at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:152)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
        at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
        at java.lang.Thread.run(Thread.java:595)
        Caused by: java.lang.IllegalArgumentException
        at java.net.URI.create(URI.java:842)
        at com.icesoft.faces.webapp.http.core.ResourceDispatcher.registerResource(ResourceDispatcher.java:101)
        at com.icesoft.faces.context.BridgeFacesContext.registerResource(BridgeFacesContext.java:621)
        at com.icesoft.faces.context.BridgeFacesContext.registerResource(BridgeFacesContext.java:613)
        at com.icesoft.faces.component.outputresource.OutputResource.getResource(OutputResource.java:85)
        at com.icesoft.faces.component.outputresource.OutputResourceRenderer.encodeBegin(OutputResourceRenderer.java:24)
        at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813)
        at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:356)
        at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:208)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
        at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358)
        at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
        at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358)
        at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
        at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358)
        at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:365)
        at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
        at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:339)
        at com.icesoft.faces.component.panelstack.PanelStackRenderer.encodeChildren(PanelStackRenderer.java:116)
        at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:517)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522)
        at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:492)
        at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153)
        at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
        ... 28 more
        Caused by: java.net.URISyntaxException: Illegal character in path at index 33: /block/resource/MjAyNjQwNTE1MA==/"icefaces.jpg"
        at java.net.URI$Parser.fail(URI.java:2816)
        at java.net.URI$Parser.checkChars(URI.java:2989)
        at java.net.URI$Parser.parseHierarchical(URI.java:3073)
        at java.net.URI$Parser.parse(URI.java:3031)
        at java.net.URI.<init>(URI.java:578)
        at java.net.URI.create(URI.java:840)
        ... 63 more

        Show
        yip.ng added a comment - Tried using the suggested encoding methods. Got the following exceptions: 14-Jul-2009 5:37:48 PM com.sun.faces.lifecycle.Phase doPhase name = /block/resource/MjAyNjQwNTE1MA==/ SEVERE: JSF1054: (Phase ID: RENDER_RESPONSE 6, View ID: /showcase.jspx) Exception thrown during phase execution: javax.faces.event.PhaseEvent [source=com.sun.faces.lifecycle.LifecycleImpl@f77511] 14-Jul-2009 5:37:48 PM com.icesoft.faces.webapp.http.core.ReceiveSendUpdates service SEVERE: Exception occured during rendering on http://localhost:8080/component-showcase-trunk/block/send-receive-updates [/showcase.jspx] javax.faces.FacesException: java.lang.IllegalArgumentException at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:128) at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139) at com.icesoft.faces.webapp.http.core.JsfLifecycleExecutor.apply(JsfLifecycleExecutor.java:19) at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.renderCycle(ReceiveSendUpdates.java:132) at com.icesoft.faces.webapp.http.core.ReceiveSendUpdates.service(ReceiveSendUpdates.java:74) at com.icesoft.faces.webapp.http.core.RequestVerifier.service(RequestVerifier.java:28) at com.icesoft.faces.webapp.http.common.standard.PathDispatcherServer.service(PathDispatcherServer.java:24) at com.icesoft.faces.webapp.http.servlet.MainSessionBoundServlet.service(MainSessionBoundServlet.java:160) at com.icesoft.faces.webapp.http.servlet.SessionDispatcher$1.service(SessionDispatcher.java:42) at com.icesoft.faces.webapp.http.servlet.ThreadBlockingAdaptingServlet.service(ThreadBlockingAdaptingServlet.java:27) at com.icesoft.faces.webapp.http.servlet.EnvironmentAdaptingServlet.service(EnvironmentAdaptingServlet.java:63) at com.icesoft.faces.webapp.http.servlet.SessionDispatcher.service(SessionDispatcher.java:62) at com.icesoft.faces.webapp.http.servlet.SessionVerifier.service(SessionVerifier.java:22) at com.icesoft.faces.webapp.http.servlet.PathDispatcher.service(PathDispatcher.java:23) at com.icesoft.faces.webapp.http.servlet.MainServlet.service(MainServlet.java:152) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at com.icesoft.faces.webapp.xmlhttp.BlockingServlet.service(BlockingServlet.java:56) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447) at java.lang.Thread.run(Thread.java:595) Caused by: java.lang.IllegalArgumentException at java.net.URI.create(URI.java:842) at com.icesoft.faces.webapp.http.core.ResourceDispatcher.registerResource(ResourceDispatcher.java:101) at com.icesoft.faces.context.BridgeFacesContext.registerResource(BridgeFacesContext.java:621) at com.icesoft.faces.context.BridgeFacesContext.registerResource(BridgeFacesContext.java:613) at com.icesoft.faces.component.outputresource.OutputResource.getResource(OutputResource.java:85) at com.icesoft.faces.component.outputresource.OutputResourceRenderer.encodeBegin(OutputResourceRenderer.java:24) at javax.faces.component.UIComponentBase.encodeBegin(UIComponentBase.java:813) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:356) at com.icesoft.faces.renderkit.dom_html_basic.GridRenderer.encodeChildren(GridRenderer.java:208) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:358) at com.icesoft.faces.renderkit.dom_html_basic.DomBasicRenderer.encodeParentAndChildren(DomBasicRenderer.java:365) at com.icesoft.faces.renderkit.dom_html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:96) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.component.util.CustomComponentUtils.renderChild(CustomComponentUtils.java:339) at com.icesoft.faces.component.panelstack.PanelStackRenderer.encodeChildren(PanelStackRenderer.java:116) at javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:837) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:517) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:522) at com.icesoft.faces.application.D2DViewHandler.renderResponse(D2DViewHandler.java:492) at com.icesoft.faces.application.D2DViewHandler.renderView(D2DViewHandler.java:153) at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110) at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100) ... 28 more Caused by: java.net.URISyntaxException: Illegal character in path at index 33: /block/resource/MjAyNjQwNTE1MA==/"icefaces.jpg" at java.net.URI$Parser.fail(URI.java:2816) at java.net.URI$Parser.checkChars(URI.java:2989) at java.net.URI$Parser.parseHierarchical(URI.java:3073) at java.net.URI$Parser.parse(URI.java:3031) at java.net.URI.<init>(URI.java:578) at java.net.URI.create(URI.java:840) ... 63 more
        Ken Fyten made changes -
        Salesforce Case []
        Fix Version/s 1.8.2 [ 10190 ]
        Assignee Priority P3
        Assignee Ken Fyten [ ken.fyten ] Yip Ng [ yip.ng ]
        Hide
        Sandro Lehmann added a comment - - edited

        If the filename contains any special chars, even a ')' the ressource can not be found:

        Firefox displays:
        Could not find resource at /intertax-web/block/resource/LTIwMjc3NjA2MzI=/Testingday_20_5__(a)_200907141213.xml

        see screenshot

        Show
        Sandro Lehmann added a comment - - edited If the filename contains any special chars, even a ')' the ressource can not be found: Firefox displays: Could not find resource at /intertax-web/block/resource/LTIwMjc3NjA2MzI=/Testingday_20_5__(a)_200907141213.xml see screenshot
        Sandro Lehmann made changes -
        Attachment fileName with '('.jpg [ 11838 ]
        Hide
        Robert Vojta added a comment -

        You can look at http://greenbytes.de/tech/tc2231/ for more info how this can be done. The problem is that there's no standard way how to do this for all browsers and you have to handle separate versions of IE as well I've workaround with the following code in Java and I pass function return value to OutputResource filename parameter. This works for IE / Firefox ...

        private static String encodeForIE(String fileName)
        throws UnsupportedEncodingException

        { /* * http://greenbytes.de/tech/tc2231/#attwithfnrawpctenca * * IE decodes %XY to characters and than if it detects * UTF-8 stream (after decoding of %XY), than it creates * UTF-8 string. * * We use this behavior to offer correct file name * for download. */ StringBuilder encodedFileName = new StringBuilder(); encodedFileName.append("\""); // ICEfaces 1.7.2 bug encodedFileName.append(URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20")); encodedFileName.append("\""); // ICEfaces 1.7.2 bug return encodedFileName.toString(); }

        private static String encodeForFirefox(String fileName)
        throws UnsupportedEncodingException {
        /*

        • http://greenbytes.de/tech/tc2231/#attwithutf8fnplain
          *
        • Firefox is trying to be smart and decodes UTF-8 characters
        • written as ISO-8859-1 bytes as UTF-8.
          *
        • We use this Firefox behavior to offer correct file name
        • for download.
          */
          StringBuilder encodedFileName = new StringBuilder();

        encodedFileName.append("\""); // ICEfaces 1.7.2 bug

        byte[] utf8Bytes = fileName.getBytes("UTF-8");
        for (byte b : utf8Bytes)

        { char ch = (char) b; encodedFileName.append(ch); }

        encodedFileName.append("\""); // ICEfaces 1.7.2 bug

        return encodedFileName.toString();
        }

        Show
        Robert Vojta added a comment - You can look at http://greenbytes.de/tech/tc2231/ for more info how this can be done. The problem is that there's no standard way how to do this for all browsers and you have to handle separate versions of IE as well I've workaround with the following code in Java and I pass function return value to OutputResource filename parameter. This works for IE / Firefox ... private static String encodeForIE(String fileName) throws UnsupportedEncodingException { /* * http://greenbytes.de/tech/tc2231/#attwithfnrawpctenca * * IE decodes %XY to characters and than if it detects * UTF-8 stream (after decoding of %XY), than it creates * UTF-8 string. * * We use this behavior to offer correct file name * for download. */ StringBuilder encodedFileName = new StringBuilder(); encodedFileName.append("\""); // ICEfaces 1.7.2 bug encodedFileName.append(URLEncoder.encode(fileName, "UTF-8").replaceAll("\\+", "%20")); encodedFileName.append("\""); // ICEfaces 1.7.2 bug return encodedFileName.toString(); } private static String encodeForFirefox(String fileName) throws UnsupportedEncodingException { /* http://greenbytes.de/tech/tc2231/#attwithutf8fnplain * Firefox is trying to be smart and decodes UTF-8 characters written as ISO-8859-1 bytes as UTF-8. * We use this Firefox behavior to offer correct file name for download. */ StringBuilder encodedFileName = new StringBuilder(); encodedFileName.append("\""); // ICEfaces 1.7.2 bug byte[] utf8Bytes = fileName.getBytes("UTF-8"); for (byte b : utf8Bytes) { char ch = (char) b; encodedFileName.append(ch); } encodedFileName.append("\""); // ICEfaces 1.7.2 bug return encodedFileName.toString(); }
        Ken Fyten made changes -
        Field Original Value New Value
        Assignee Ken Fyten [ ken.fyten ]
        Robert Vojta created issue -

          People

          • Assignee:
            yip.ng
            Reporter:
            Robert Vojta
          • Votes:
            13 Vote for this issue
            Watchers:
            10 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: