* Andr� Malo wrote:

> the attached patch deals somehow with
> <http://nagoya.apache.org/bugzilla/show_bug.cgi?id 284>. It makes it
> configurable whether mod_speling should ignore requested dotfiles.

Oh dear, the patch was not sufficient. Here comes the full one.
Anyway, I'm not sure whether this makes sense at all, so any comments are
welcome :)

nd
diff -Nur httpd-2.1~/modules/mappers/mod_speling.c httpd-2.1/modules/mappers/mod_speling.c
--- httpd-2.1~/modules/mappers/mod_speling.c
+++ httpd-2.1/modules/mappers/mod_speling.c
@@ -135,13 +135,26 @@
 }
 
 /*
- * Handler for the CheckSpelling directive, which is FLAG.
+ * Handler for the CheckSpelling directive
  */
-static const char *set_speling(cmd_parms *cmd, void *mconfig, int arg)
+static const char *set_speling(cmd_parms *cmd, void *mconfig, const char *arg)
 {
     spconfig *cfg = (spconfig *) mconfig;
 
-    cfg->enabled = arg;
+    if (!strcasecmp(arg, "Off")) {
+        cfg->enabled = 0;
+    }
+    else if (!strcasecmp(arg, "On")) {
+        cfg->enabled = 1;
+    }
+    else if (!strcasecmp(arg, "WithoutDotfiles")) {
+        cfg->enabled = 2;
+    }
+    else {
+        return "CheckSpelling argument must be one of 'On', 'Off' or"
+               "WithoutDotfiles.";
+    }
+
     return NULL;
 }
 
@@ -151,8 +164,8 @@
  */
 static const command_rec speling_cmds[] =
 {
-    AP_INIT_FLAG("CheckSpelling", set_speling, NULL, OR_OPTIONS,
-                 "whether or not to fix miscapitalized/misspelled requests"),
+    AP_INIT_TAKE1("CheckSpelling", set_speling, NULL, OR_OPTIONS,
+                  "whether or not to fix miscapitalized/misspelled requests"),
     { NULL }
 };
 
@@ -314,6 +327,12 @@
     candidates = apr_array_make(r->pool, 2, sizeof(misspelled_file));
 
     dotloc = ap_ind(bad, '.');
+    
+    /* exclude dotfiles if configured so */
+    if (dotloc == 0 && cfg->enabled == 2) {
+        return DECLINED;
+    }
+
     if (dotloc == -1) {
         dotloc = strlen(bad);
     }
@@ -329,6 +348,11 @@
         if (strcmp(bad, dirent.name) == 0) {
             apr_dir_close(dir);
             return OK;
+        }
+
+        /* exclude dotfiles if configured so */
+        if (*dirent.name == '.' && cfg->enabled == 2) {
+            continue;
         }
 
         /*

Reply via email to