]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
Backport mod_speling enhancement
authorNick Kew <niq@apache.org>
Wed, 26 Jul 2006 08:18:53 +0000 (08:18 +0000)
committerNick Kew <niq@apache.org>
Wed, 26 Jul 2006 08:18:53 +0000 (08:18 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.2.x@425670 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
STATUS
docs/manual/mod/mod_speling.xml
modules/mappers/mod_speling.c

diff --git a/CHANGES b/CHANGES
index 54d9606e7e90ee4b44e55660d1fd39c04cdfeafb..bc34cdc95873e4169fbd2f5d67a1103bb7da883d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,9 @@
                                                         -*- coding: utf-8 -*-
 Changes with Apache 2.2.3
 
+  *) mod_speling: Add directive to deal with case corrections only
+     and ignore other misspellings [Olivier Thereaux  <ot w3.org>]
+
   *) mod_dbd: Fix dependence on virtualhost configuration in
      defining prepared statements (possible segfault at startup
      in user modules such as mod_authn_dbd).  [Nick Kew]
diff --git a/STATUS b/STATUS
index 7f415a84c955d9638c03c71128f7be697c359343..993d2b70b2d36c799c3bbef3690653df213a7434 100644 (file)
--- a/STATUS
+++ b/STATUS
@@ -97,12 +97,6 @@ PATCHES ACCEPTED TO BACKPORT FROM TRUNK:
        +1: bnicholes, wrowe, fielding
          wrowe observes; CONST==result is a horrid style convention
 
-    * mod_speling: add option to do case-normalisation only
-      Patch submitted by Olivier Thereaux
-      http://svn.apache.org/viewvc?view=rev&revision=411849
-      http://svn.apache.org/viewvc?rev=414146&view=rev
-      +1: niq, pquerna, fielding
-
 PATCHES PROPOSED TO BACKPORT FROM TRUNK:
 
     * Bundled PCRE: backport r381783 from trunk
index 65586bbac30cb1c0460697a1e5f821f95442caf6..f53a2637bd372db84b0ada7965a1bc1fd68c24e9 100644 (file)
@@ -117,4 +117,24 @@ of Apache 1.3, it is part of the Apache distribution. Prior to Apache
 </usage>
 </directivesynopsis>
 
+<directivesynopsis>
+<name>CheckCaseOnly</name>
+<description>Limits the action of the speling module to case corrections</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>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>
+
 </modulesynopsis>
index c82e1ac86f4ba0c80efd40bc13ddba3ad36437c6..270b47eeec3163021878fb3d185134ee6d3f4b80 100644 (file)
@@ -36,6 +36,9 @@
  * misspellings of URLs that users might have entered, namely by checking
  * capitalizations. If it finds a match, it sends a redirect.
  *
+ * Sep-1999 Hugo Haas <hugo@w3.org>
+ * o Added a CheckCaseOnly option to check only miscapitalized words.
+ *
  * 08-Aug-1997 <Martin.Kraemer@Mch.SNI.De>
  * o Upgraded module interface to apache_1.3a2-dev API (more NULL's in
  *   speling_module).
@@ -56,6 +59,7 @@ module AP_MODULE_DECLARE_DATA speling_module;
 
 typedef struct {
     int enabled;
+    int case_only;
 } spconfig;
 
 /*
@@ -72,6 +76,7 @@ static void *mkconfig(apr_pool_t *p)
     spconfig *cfg = apr_pcalloc(p, sizeof(spconfig));
 
     cfg->enabled = 0;
+    cfg->case_only = 0;
     return cfg;
 }
 
@@ -92,25 +97,18 @@ static void *create_mconfig_for_directory(apr_pool_t *p, char *dir)
     return mkconfig(p);
 }
 
-/*
- * Handler for the CheckSpelling directive, which is FLAG.
- */
-static const char *set_speling(cmd_parms *cmd, void *mconfig, int arg)
-{
-    spconfig *cfg = (spconfig *) mconfig;
-
-    cfg->enabled = arg;
-    return NULL;
-}
-
 /*
  * Define the directives specific to this module.  This structure is referenced
  * later by the 'module' structure.
  */
 static const command_rec speling_cmds[] =
 {
-    AP_INIT_FLAG("CheckSpelling", set_speling, NULL, OR_OPTIONS,
+    AP_INIT_FLAG("CheckSpelling", ap_set_flag_slot,
+                  (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, 
+                 "whether or not to fix only miscapitalized requests"),
     { NULL }
 };
 
@@ -310,7 +308,8 @@ static int check_speling(request_rec *r)
          * simple typing errors are checked next (like, e.g.,
          * missing/extra/transposed char)
          */
-        else if ((q = spdist(bad, dirent.name)) != SP_VERYDIFFERENT) {
+        else if ((cfg->case_only == 0)
+                 && ((q = spdist(bad, dirent.name)) != SP_VERYDIFFERENT)) {
             misspelled_file *sp_new;
 
             sp_new = (misspelled_file *) apr_array_push(candidates);