All,

We had a need here for mod_speling's case-correcting functionality but we have generated filenames with very similar names so we were constantly running afoul of its willingness to substitute the "wrong" file when the correct one did not exist. I made a simple addition to mod_speling to restrict it to case comparisons only, and added a configuration flag "CheckCaseOnly" to enable or disable it. The default behavior is as before.

Doc XML update is also included in the patch, against 2.0.53.

Sent here in the hopes that it might get picked up or at least be useful to people who are in the same boat we are.

-m

diff -Naur httpd-2.0.53-orig/docs/manual/mod/mod_speling.xml 
httpd-2.0.53/docs/manual/mod/mod_speling.xml
--- httpd-2.0.53-orig/docs/manual/mod/mod_speling.xml   2005-03-08 
13:44:26.000000000 -0600
+++ httpd-2.0.53/docs/manual/mod/mod_speling.xml        2005-03-08 
13:45:46.000000000 -0600
@@ -25,7 +25,7 @@
 <name>mod_speling</name>
 <description>Attempts to correct mistaken URLs that
 users might have entered by ignoring capitalization and by
-allowing up to one misspelling</description>
+(potentially) allowing up to one misspelling</description>
 <status>Extension</status>
 <sourcefile>mod_speling.c</sourcefile>
 <identifier>speling_module</identifier>
@@ -109,6 +109,31 @@
     </ul>
 </usage>
 
+<name>CheckCaseOnly</name>
+<description>Restricts the spelling module to
+correcting miscapitalizations
+</description>
+<syntax>CheckCaseOnly on|off</syntax>
+<default>CheckCaseOnly 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 restricts the spelling corrections to changes
+    in case.  This is useful if you are moving from a case-insensitive
+    system to a case-sensitive one and your users have become
+    accustomed to using URLs in a case-insensitive manner, but you
+    do not want to enable corrections for misspelled names.
+    </p>
+
+</usage>
+
 </directivesynopsis>
 
 </modulesynopsis>
diff -Naur httpd-2.0.53-orig/modules/mappers/mod_speling.c 
httpd-2.0.53/modules/mappers/mod_speling.c
--- httpd-2.0.53-orig/modules/mappers/mod_speling.c     2005-03-08 
13:44:26.000000000 -0600
+++ httpd-2.0.53/modules/mappers/mod_speling.c  2005-03-08 13:45:11.000000000 
-0600
@@ -49,6 +49,10 @@
  *   omitted.
  * o wrote a "kind of" html page for mod_speling
  *
+ * 07-Mar-2005 <[EMAIL PROTECTED]>
+ * o Added "CheckCaseOnly" option to only allow case fiddling and not
+ *   the full range of spelling corrections.
+ *
  * Activate it with "CheckSpelling On"
  */
 
@@ -56,6 +60,7 @@
 
 typedef struct {
     int enabled;
+    int case_only;
 } spconfig;
 
 /*
@@ -72,6 +77,7 @@
     spconfig *cfg = apr_pcalloc(p, sizeof(spconfig));
 
     cfg->enabled = 0;
+    cfg->case_only = 0;
     return cfg;
 }
 
@@ -104,6 +110,17 @@
 }
 
 /*
+ * Handler for the CheckCaseOnly directive, which is FLAG.
+ */
+static const char *set_case_only(cmd_parms *cmd, void *mconfig, int arg)
+{
+    spconfig *cfg = (spconfig *) mconfig;
+
+    cfg->case_only = arg;
+    return NULL;
+}
+
+/*
  * Define the directives specific to this module.  This structure is referenced
  * later by the 'module' structure.
  */
@@ -111,6 +128,8 @@
 {
     AP_INIT_FLAG("CheckSpelling", set_speling, NULL, OR_OPTIONS,
                  "whether or not to fix miscapitalized/misspelled requests"),
+    AP_INIT_FLAG("CheckCaseOnly", set_case_only, NULL, OR_OPTIONS,
+                 "whether or not to correct only miscapitalizations"),
     { NULL }
 };
 
@@ -293,6 +312,12 @@
            sp_new = (misspelled_file *) apr_array_push(candidates);
             sp_new->name = apr_pstrdup(r->pool, dirent.name);
             sp_new->quality = SP_MISCAPITALIZED;
+           /*
+            * if we are just checking for miscapitalizations, then there's
+            * no reason to continue on.
+            */
+           if (cfg->case_only) 
+               continue;
         }
 
         /*

Reply via email to