core icon indicating copy to clipboard operation
core copied to clipboard

IIS + can`t download/open files with special characters

Open ForumSchlampe opened this issue 12 years ago • 7 comments

Expected behaviour Single click on a file with special characters in the webUI should start the download -> Works for files without any special character (like german umlauts)

Actual behaviour Single click on a file with or without Special characters should open/start the download. Downloadbutton works for such files but this isnt handy...and users got confused cause some files work this way and others not.

Steps to reproduce

  1. Open web ui and login
  2. Upload a file with the Name like "täst.pdf"
  3. Click on the filename after upload

Server configuration IIS 7.5 PHP 5.5 Windows Server 2008 R2 MySQL Internal Storage (NTFS)

Client configuration OS: Windows 7, OSX Browser: IE10/11, Firefox, Opera, Chrome, Safari

Operating system: Windows 7 OSX

ForumSchlampe avatar Dec 09 '13 16:12 ForumSchlampe

@ringmaster Can you reproduce that?

karlitschek avatar Dec 09 '13 16:12 karlitschek

Yes, I can reproduce this on OC6. Looking into it now.

ringmaster avatar Dec 09 '13 17:12 ringmaster

This issue has to do with how IIS handles url-encoded URLs before passing them on to FastCGI apps. Normally, the URLs (the PATH_INFO part) are decoded before they're forwarded to FastCGI (including PHP). Because of this, UTF-8 URLs that include the downloadable file within the path (not the querystring) are decoded and passed on to PHP. But IIS decodes URLs only to ASCII by default. This results in incorrect path URLs being forwarded to the PHP CGI, which is why ownCloud is unable to find files with UTF-8 characters for download.

By contrast, IIS does not decode the querystring of URLs before passing them to the FastCGI apps. This is why clicking on the download link in the file list (which generates a different URL that includes the filename as part of the querystring) is successful.

To fix this issue, IIS must be convinced to decode UTF-8 URLs as UTF-8, and not ASCII, before passing them on to the PHP CGI application.

I was able to successfully accomplish this by changing a registry setting on the IIS server, which sets the encoding for the REQUEST_URI and PATH_INFO server variables to UTF-8. Follow these steps:

  1. Open a console window with administrative privileges.
  2. Run this command to adjust the registry settings: reg add HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\w3svc\Parameters /v FastCGIUtf8ServerVariables /t REG_MULTI_SZ /d REQUEST_URI\0PATH_INFO
  3. Restart IIS.

After completing these steps, UTF-8 URLs should be forwarded correctly to PHP, and the encoded filenames should properly download.

@ForumSchlampe please try this fix and report your results. This could be very helpful to others who have a similar issue.

ringmaster avatar Dec 09 '13 18:12 ringmaster

@ringmaster works for me, thanks

Maybe there should be a hint in the install documentation to enable this by default for Windows/IIS installations....think this should be highly recomended.

ForumSchlampe avatar Dec 09 '13 21:12 ForumSchlampe

@ringmaster awesome. Do you think we can add this to the documentation?

karlitschek avatar Dec 10 '13 09:12 karlitschek

I have a PHP script that uploads docs manually to moodle, This script doesn't work with documents containing any special character (like Arabic) in the file name I am using Windows Server 2012 R2 Standard and I am running the script from cmd

AnthonyAoun1 avatar Jan 11 '16 06:01 AnthonyAoun1

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Aug 07 '19 01:08 lock[bot]