From 409bc6238b423c79af6733c0061c7cf9a7b2acc2 Mon Sep 17 00:00:00 2001 From: Christophe Jaillet Date: Sun, 12 Jan 2014 18:11:04 +0000 Subject: [PATCH] - Rename variable - Remove #define WANT_BASENAME_MATCH and define a new option 'CheckBasenameMatch' to control this behaviour - Remove outdated comments git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1557580 13f79535-47bb-0310-9956-ffa450edef68 --- docs/manual/mod/mod_speling.xml | 25 +++++++++++++++++++++- modules/mappers/mod_speling.c | 37 ++++++++++++++------------------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/docs/manual/mod/mod_speling.xml b/docs/manual/mod/mod_speling.xml index 4219c2f66c..e88916abe8 100644 --- a/docs/manual/mod/mod_speling.xml +++ b/docs/manual/mod/mod_speling.xml @@ -126,10 +126,33 @@ module Options -

When set, this directive limits the action of the spelling correction to lower/upper case changes. +

When set, this directive limits the action of the spelling correction + to lower/upper case changes. Other potential corrections are not performed.

+ +CheckBasenameMatch +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 +MultiViews +CheckBasenameMatch on|off +CheckBasenameMatch Off + +server config +virtual host +directory +.htaccess + +Options + + +

This option has no effect if CheckCaseOnly is set.

+ +
+
+ diff --git a/modules/mappers/mod_speling.c b/modules/mappers/mod_speling.c index 0fca44eda0..4d8a942bc1 100644 --- a/modules/mappers/mod_speling.c +++ b/modules/mappers/mod_speling.c @@ -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_module; 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 * - * 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); -- 2.50.1