summaryrefslogtreecommitdiffstats
path: root/modules/mappers/mod_speling.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-25 04:41:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-25 04:41:28 +0000
commitb1a1c1d95059e2fefd7b5671eb110ab690409a84 (patch)
tree97ecfcc9425e2d09d2cd669594d626a616f324a3 /modules/mappers/mod_speling.c
parentReleasing progress-linux version 2.4.38-3+deb10u10progress5u1. (diff)
downloadapache2-b1a1c1d95059e2fefd7b5671eb110ab690409a84.tar.xz
apache2-b1a1c1d95059e2fefd7b5671eb110ab690409a84.zip
Merging upstream version 2.4.59.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'modules/mappers/mod_speling.c')
-rw-r--r--modules/mappers/mod_speling.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/modules/mappers/mod_speling.c b/modules/mappers/mod_speling.c
index 3e97423..2ed65eb 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 = 1;
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,14 @@ 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 {
-#ifdef WANT_BASENAME_MATCH
+ else if (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 +351,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);
@@ -425,6 +419,7 @@ static int check_speling(request_rec *r)
if (apr_pool_create(&sub_pool, p) != APR_SUCCESS)
return DECLINED;
+ apr_pool_tag(sub_pool, "speling_sub");
t = apr_array_make(sub_pool, candidates->nelts * 8 + 8,
sizeof(char *));