Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-580

Directory names matched as file extensions when determining mime type

XMLWordPrintable

    • Hide

      1. Deploy an application with a directory "/css" in web root.
      2. Point a browser at the "/css" resource
      3. Empty content with status code 200 and mime type "text/css" is served

      Show
      1. Deploy an application with a directory "/css" in web root. 2. Point a browser at the "/css" resource 3. Empty content with status code 200 and mime type "text/css" is served

      Undertow incorrectly resolves the MIME type for resources that are usually directories (i.e. they have no file extension) in ServerContextImpl:

       @Override
          public String getMimeType(final String file) {
              if(file == null) {
                  return null;
              }
              String lower = file.toLowerCase(Locale.ENGLISH);
              int pos = lower.lastIndexOf('.');
              if (pos == -1) {
                  return deployment.getMimeExtensionMappings().get(lower);
              }
              return deployment.getMimeExtensionMappings().get(lower.substring(pos + 1));
          }
      

      Even for a directoty named "foo.css" I wouldn't expect the server to return such a MIME type. IMHO, the implemenation should check if the resource is a directory and return null in this case. It also makes sense to return null when file has no extension (instead of treating the file name as a one).

              sdouglas1@redhat.com Stuart Douglas (Inactive)
              lqc_jira Ɓukasz Rekucki (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: