httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jaillet...@apache.org
Subject svn commit: r1557580 - in /httpd/httpd/trunk: docs/manual/mod/mod_speling.xml modules/mappers/mod_speling.c
Date Sun, 12 Jan 2014 18:11:04 GMT
Author: jailletc36
Date: Sun Jan 12 18:11:04 2014
New Revision: 1557580

URL: http://svn.apache.org/r1557580
Log:
- Rename variable
- Remove #define WANT_BASENAME_MATCH and define a new option 'CheckBasenameMatch' to control
this behaviour
- Remove outdated comments

Modified:
    httpd/httpd/trunk/docs/manual/mod/mod_speling.xml
    httpd/httpd/trunk/modules/mappers/mod_speling.c

Modified: httpd/httpd/trunk/docs/manual/mod/mod_speling.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mod_speling.xml?rev=1557580&r1=1557579&r2=1557580&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mod_speling.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mod_speling.xml Sun Jan 12 18:11:04 2014
@@ -126,10 +126,33 @@ module</description>
 <override>Options</override>
 
 <usage>
-    <p>When set, this directive limits the action of the spelling correction to lower/upper
case changes.
+    <p>When set, this directive limits the action of the spelling correction
+    to lower/upper case changes.
     Other potential corrections are not performed.</p>
 
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>CheckBasenameMatch</name>
+<description>Extend the action of the speling module to also check filename
+without paying attention to the extention. (e.g. foo.gif and foo.jpg).
+This can be particulary useful in conjunction with
+<a href="../content-negotiation.html">MultiViews</a></description>
+<syntax>CheckBasenameMatch on|off</syntax>
+<default>CheckBasenameMatch Off</default>
+<contextlist>
+<context>server config</context>
+<context>virtual host</context>
+<context>directory</context>
+<context>.htaccess</context>
+</contextlist>
+<override>Options</override>
+
+<usage>
+    <p>This option has no effect if <directive>CheckCaseOnly</directive>
is set.</p>
+
+</usage>
+</directivesynopsis>
+
 </modulesynopsis>

Modified: httpd/httpd/trunk/modules/mappers/mod_speling.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_speling.c?rev=1557580&r1=1557579&r2=1557580&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_speling.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_speling.c Sun Jan 12 18:11:04 2014
@@ -22,8 +22,6 @@
 #define APR_WANT_STRFUNC
 #include "apr_want.h"
 
-#define WANT_BASENAME_MATCH
-
 #include "httpd.h"
 #include "http_core.h"
 #include "http_config.h"
@@ -59,7 +57,8 @@ module AP_MODULE_DECLARE_DATA speling_mo
 
 typedef struct {
     int enabled;
-    int case_only;
+    int check_case_only;
+    int check_basename_match;
 } spconfig;
 
 /*
@@ -76,7 +75,8 @@ static void *mkconfig(apr_pool_t *p)
     spconfig *cfg = apr_pcalloc(p, sizeof(spconfig));
 
     cfg->enabled = 0;
-    cfg->case_only = 0;
+    cfg->check_case_only = 0;
+    cfg->check_basename_match = 0;
     return cfg;
 }
 
@@ -107,8 +107,11 @@ static const command_rec speling_cmds[] 
                   (void*)APR_OFFSETOF(spconfig, enabled), OR_OPTIONS,
                  "whether or not to fix miscapitalized/misspelled requests"),
     AP_INIT_FLAG("CheckCaseOnly", ap_set_flag_slot,
-                  (void*)APR_OFFSETOF(spconfig, case_only), OR_OPTIONS,
+                  (void*)APR_OFFSETOF(spconfig, check_case_only), OR_OPTIONS,
                  "whether or not to fix only miscapitalized requests"),
+    AP_INIT_FLAG("CheckBasenameMatch", ap_set_flag_slot,
+                  (void*)APR_OFFSETOF(spconfig, check_basename_match), OR_OPTIONS,
+                 "whether or not to fix files with the same base name"),
     { NULL }
 };
 
@@ -302,7 +305,7 @@ static int check_speling(request_rec *r)
          * simple typing errors are checked next (like, e.g.,
          * missing/extra/transposed char)
          */
-        else if ((cfg->case_only == 0)
+        else if ((cfg->check_case_only == 0)
                  && ((q = spdist(bad, dirent.name)) != SP_VERYDIFFERENT)) {
             misspelled_file *sp_new;
 
@@ -316,22 +319,15 @@ static int check_speling(request_rec *r)
          * requests.  It is of questionable use to continue looking for
          * files with the same base name, but potentially of totally wrong
          * type (index.html <-> index.db).
-         * I would propose to not set the WANT_BASENAME_MATCH define.
-         *      08-Aug-1997 <Martin.Kraemer@Mch.SNI.De>
          *
-         * However, Alexei replied giving some reasons to add it anyway:
-         * > Oh, by the way, I remembered why having the
-         * > extension-stripping-and-matching stuff is a good idea:
-         * >
-         * > If you're using MultiViews, and have a file named foobar.html,
-         * > which you refer to as "foobar", and someone tried to access
-         * > "Foobar", mod_speling won't find it, because it won't find
-         * > anything matching that spelling. With the extension-munging,
-         * > it would locate "foobar.html". Not perfect, but I ran into
-         * > that problem when I first wrote the module.
+         * If you're using MultiViews, and have a file named foobar.html,
+         * which you refer to as "foobar", and someone tried to access
+         * "Foobar", without CheckBasenameMatch, mod_speling won't find it,
+         * because it won't find anything matching that spelling.
+         * With the extension-munging, it would locate "foobar.html".
          */
-        else if (cfg->case_only == 0) {
-#ifdef WANT_BASENAME_MATCH
+        else if ((cfg->check_case_only == 0) &&
+                 (cfg->check_basename_match == 1)) {
             /*
              * Okay... we didn't find anything. Now we take out the hard-core
              * power tools. There are several cases here. Someone might have
@@ -356,7 +352,6 @@ static int check_speling(request_rec *r)
                 sp_new->name = apr_pstrdup(r->pool, dirent.name);
                 sp_new->quality = SP_VERYDIFFERENT;
             }
-#endif
         }
     }
     apr_dir_close(dir);



Mime
View raw message