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

        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.
        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
        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
        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.
        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.

          People

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

            Dates

            • Created:
              Updated:
              Resolved: