You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Maurice Aubrey <ma...@hevanet.com> on 2002/01/31 04:48:33 UTC

MultiViews no longer working with SetHandler

I'm using MultiViews to prevent the file extensions of
of my mod_perl scripts from being exposed.

The stanza I was using successfully with Apache 1.3.19 was:

  <Files ~ "\\.mp\$">
    Options +ExecCGI
    SetHandler perl-script
    PerlHandler Apache::Registry
    PerlSendHeader On
  </Files>

With Apache 1.3.23 I now receive file not found errors when
requesting scripts with the .mp extension omitted.

I believe the relevant change was made in Apache 1.3.21.
>From the change log:

  Modified mod_mime and mod_negotiation to prevent mod_negotiation 
  from serving any multiview variant containing one or more 
  'unknown' filename extensions. In PR #8130, mod_negotiation was 
  incorrectly serving index.html.zh.Big5 when better variants were 
  available. The httpd.conf file on the failing server did not have 
  an AddLanguage directive for .zh, which caused mod_mime to loose
  the file_type information it gleened from parsing the .html
  extension. The absence of any language preferences, either in
  the browser or configured on the server, caused mod_negotiation
  to consider all the variants equivalent. When that occurs, 
  mod_negotiation picks the 'smallest' variant available, which
  just happened to be  index.html.zh.Big5.
  [Bill Stoddard, Bill Rowe] PR #8130

>From looking at mod_negotiation.c, it seems that if mod_mime
doesn't understand the extension then the file is rejected as
a candidate.  The comments state:

  /*
  * mod_mime will _always_ provide us the base name in the
  * ap-mime-exception-list, if it processed anything.  If
  * this list is empty, give up immediately, there was
  * nothing interesting.  For example, looking at the files
  * readme.txt and readme.foo, we will throw away .foo if
  * it's an insignificant file (e.g. did not identify a
  * language, charset, encoding, content type or handler,)
  */

In this case, however, it seems like the script
should not be rejected since the SetHandler directive does
assign a handler to the file even if mod_mime is not part of
that process.

There is a work-around, which is to add an AddHandler 
directive to make mod_mime happy:

  AddHandler perl-script .mp
  <Files ~ "\\.mp\$">
    Options +ExecCGI
    SetHandler perl-script
    PerlHandler Apache::Registry
    PerlSendHeader On
  </Files>

But is that correct behavior?  Should the AddHandler be required
to use MultiViews?

I'm including a small patch which prevents subrequests
that have a handler assigned from being skipped but
I'm not sure if this is the correct solution.

Thanks,

Maurice

--- apache_1.3.23/src/modules/standard/mod_negotiation.c.orig	Wed Jan 30 16:37:55 2002
+++ apache_1.3.23/src/modules/standard/mod_negotiation.c	Wed Jan 30 19:13:48 2002
@@ -967,7 +967,7 @@
         exception_list = 
             (array_header *) ap_table_get(sub_req->notes,
                                           "ap-mime-exceptions-list");
-        if (!exception_list) {
+        if (!exception_list && !sub_req->handler) {
             ap_destroy_sub_req(sub_req);
             continue;
         }
@@ -978,7 +978,7 @@
          * because that would introduce too much CPU consumption.  Better that
          * we don't attempt a many-to-many match here.
          */
-        {
+        if (exception_list) {
             int nexcept = exception_list->nelts;
             char **cur_except = (char**)exception_list->elts;
             char *segstart = filp, *segend, saveend;

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org