Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-30814

Resource: uploaded file with accent within its name gives error when trying to access it

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Not a bug
    • Affects Version/s: 2.2
    • Fix Version/s: None
    • Component/s: Resource
    • Labels:
      None
    • Environment:
      Windows 2008 64bits, IIS 7.5, MySQL 5.1
    • Database:
      MySQL
    • Testing Instructions:
      Hide

      Upload "Fiche étudiant.pdf" as a resource in a course. Upload is successfull and we can find the corresponding hashed file in the moodledata dir. However, when we try to click the link to see the file, we got an "Sorry, the requested file could not be found" error. Same file without an "é" ("Fiche etudiant.pdf") however works well.

      Show
      Upload "Fiche étudiant.pdf" as a resource in a course. Upload is successfull and we can find the corresponding hashed file in the moodledata dir. However, when we try to click the link to see the file, we got an "Sorry, the requested file could not be found" error. Same file without an "é" ("Fiche etudiant.pdf") however works well.
    • Affected Branches:
      MOODLE_22_STABLE

      Description

      File resource in a course uploaded successfully even with an have accent in its name ("é, è, û, etc.") but when we try to access it, it give a "Sorry, the requested file could not be found" error.

        Gliffy Diagrams

          Activity

          Hide
          skodak Petr Skoda added a comment -

          Hello,

          unfortunately in is very difficult to configure the IIS to work with unicode chars in "slasharguments". See http://docs.moodle.org/22/en/Installation_for_Windows_2003_with_IIS for more details.

          The low level problem is that in some configuration IIS converts these UTF-8 chars to DOS 8-bit encoding in the current locale, the trick is to somehow prevent this, the easies way might be to set up some URL rewriting.

          Petr

          Show
          skodak Petr Skoda added a comment - Hello, unfortunately in is very difficult to configure the IIS to work with unicode chars in "slasharguments". See http://docs.moodle.org/22/en/Installation_for_Windows_2003_with_IIS for more details. The low level problem is that in some configuration IIS converts these UTF-8 chars to DOS 8-bit encoding in the current locale, the trick is to somehow prevent this, the easies way might be to set up some URL rewriting. Petr
          Hide
          jackdaniels JD added a comment -

          For anybody who come accross this post and have the same problem, it have been relsolved by following the link provided by Petr and learning a little bit how to work with URL Rewrite (http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/).
          1- You need to have a web server with the ASP.NET role enabled
          2- If you have IIS 7.0, you need to install URL Rewrite Module (http://www.iis.net/download/URLRewrite)
          3- Create a blank inbound rule with the following info and... that all! So far, upload with french caracters now work properly and nothing was broken elsewhere.

          Match url
          . Requested URL: Matches the Pattern
          . Using: Regular expression
          . Pattern: ^([^\?]?\.php)(\/.)$
          . Ignore case: checked

          Conditions
          . none

          Server variables
          . none

          Action
          . Action type: rewrite
          . Action properties > Rewrite URL:

          {R:1}

          ?file=

          {R:2}

          . Append URL String: checked

          Show
          jackdaniels JD added a comment - For anybody who come accross this post and have the same problem, it have been relsolved by following the link provided by Petr and learning a little bit how to work with URL Rewrite ( http://learn.iis.net/page.aspx/461/creating-rewrite-rules-for-the-url-rewrite-module/ ). 1- You need to have a web server with the ASP.NET role enabled 2- If you have IIS 7.0, you need to install URL Rewrite Module ( http://www.iis.net/download/URLRewrite ) 3- Create a blank inbound rule with the following info and... that all! So far, upload with french caracters now work properly and nothing was broken elsewhere. Match url . Requested URL: Matches the Pattern . Using: Regular expression . Pattern: ^( [^\?] ?\.php)(\/. )$ . Ignore case: checked Conditions . none Server variables . none Action . Action type: rewrite . Action properties > Rewrite URL: {R:1} ?file= {R:2} . Append URL String: checked
          Hide
          dcosta Daniel Costa added a comment -

          Hi,

          I have a moodle 2.3 and 1.9 running on the same server. If I apply the url rewrite described above, can I have problems with my old files or everything stays fine?

          TIA

          Daniel

          Show
          dcosta Daniel Costa added a comment - Hi, I have a moodle 2.3 and 1.9 running on the same server. If I apply the url rewrite described above, can I have problems with my old files or everything stays fine? TIA Daniel
          Hide
          jackdaniels JD added a comment - - edited

          Hi,

          You should have two different web site in IIS for both version, correct? You can set the url rewrite rule only for the Moodle 2.3 web site, leaving the 1.9 untouched. Just put the web.config file in the 2.3 web site root :

          <?xml version="1.0" encoding="UTF-8"?>
          <configuration>
              <system.webServer>
                  <rewrite>
                      <rules>
                          <rule name="Moodle - Règle pour les fichiers avec accent (ne pas effacer)">
                              <match url="^([^\?]+?\.php)(\/.+)$" />
                              <action type="Rewrite" url="{R:1}\?file={R:2}" />
                          </rule>
                      </rules>
                  </rewrite>
              </system.webServer>
          </configuration>

          (EDIT)
          Note that if you already have a web.config file, you'll need to edit it and add the <rewrite> part above in the system.webServer node.

          Show
          jackdaniels JD added a comment - - edited Hi, You should have two different web site in IIS for both version, correct? You can set the url rewrite rule only for the Moodle 2.3 web site, leaving the 1.9 untouched. Just put the web.config file in the 2.3 web site root : <? xml version = "1.0" encoding = "UTF-8" ?> < configuration > < system .webServer> < rewrite > < rules > < rule name = "Moodle - Règle pour les fichiers avec accent (ne pas effacer)" > < match url = "^([^\?]+?\.php)(\/.+)$" /> < action type = "Rewrite" url = "{R:1}\?file={R:2}" /> </ rule > </ rules > </ rewrite > </ system .webServer> </ configuration > (EDIT) Note that if you already have a web.config file, you'll need to edit it and add the <rewrite> part above in the system.webServer node.
          Hide
          dcosta Daniel Costa added a comment - - edited

          Thank's for the answer. Yes, that is exactly how I have it. I'll do it tomorrow and let you know.

          Show
          dcosta Daniel Costa added a comment - - edited Thank's for the answer. Yes, that is exactly how I have it. I'll do it tomorrow and let you know.

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: