martin 98/01/13 15:29:13
Modified: . STATUS
src CHANGES
src/modules/standard mod_speling.c
Log:
Mod_speling would return "multiple choices" with invalid HREF links, when
finding an abiguous spelling correction. It now returns absolute links,
as it did in the case of a single matching spelling correction.
Submitted by: [EMAIL PROTECTED] (Soeren Ziehe)
Reviewed by: Dean Gaudet +1, Jim Jagielski +1, Soeren Ziehe +1
Revision Changes Path
1.86 +1 -5 apachen/STATUS
Index: STATUS
===================================================================
RCS file: /home/cvs/apachen/STATUS,v
retrieving revision 1.85
retrieving revision 1.86
diff -u -u -r1.85 -r1.86
--- STATUS 1998/01/13 23:10:53 1.85
+++ STATUS 1998/01/13 23:28:59 1.86
@@ -80,6 +80,7 @@
* Brian Havard's [Patch] OS/2 - fix up shut down
* Dean's [PATCH] make mod_rewrite use ap_cpystrn
* Martin's [PORT] Make apache compile & run on an EBCDIC mainframe
+ * Martin's [PATCH] mod_speling [300] Multiple Choices bug (Take 2)
Available Patches:
@@ -102,11 +103,6 @@
* Dean's [PATCH] yet another slow function
<[EMAIL PROTECTED]>
Status: Dean +1, Jim +1, Martin +1, Paul +1
-
- * Martin's [PATCH] mod_speling [300] Multiple Choices bug (Take 2)
- Submitted by: Soeren Ziehe <[EMAIL PROTECTED]>
- <[EMAIL PROTECTED]>
- Status: Martin +1, Dean +1, Jim +1, Soeren +1, [EMAIL PROTECTED] +1
* Marc's [PATCH] PR#1543: suexec logging exec failures
<[EMAIL PROTECTED]>
1.565 +8 -0 apachen/src/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/apachen/src/CHANGES,v
retrieving revision 1.564
retrieving revision 1.565
diff -u -u -r1.564 -r1.565
--- CHANGES 1998/01/13 21:19:07 1.564
+++ CHANGES 1998/01/13 23:29:10 1.565
@@ -1,5 +1,13 @@
Changes with Apache 1.3b4
+ *) Mod_speling returned incorrect HREF's when an ambigous match
+ was found. Noticed by <[EMAIL PROTECTED]> (Soeren Ziehe)
+ [EMAIL PROTECTED] (Soeren Ziehe), Martin Kraemer]
+
+ *) PORT: Apache now compiles & runs on an EBCDIC mainframe
+ (the Siemens Nixdorf BS2000-OSD family) in the POSIX subsystem
+ [Martin Kraemer]
+
*) PORT: Fix problem killing children when terminating. Allow ^C
to shut down the server. [Brian Havard]
1.11 +31 -23 apachen/src/modules/standard/mod_speling.c
Index: mod_speling.c
===================================================================
RCS file: /home/cvs/apachen/src/modules/standard/mod_speling.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -u -r1.10 -r1.11
--- mod_speling.c 1998/01/13 22:47:38 1.10
+++ mod_speling.c 1998/01/13 23:29:13 1.11
@@ -93,14 +93,14 @@
void *server_conf = cmd->server->module_config;
/* any non-NULL pointer means speling is enabled */
- set_module_config(server_conf, &speling_module, arg ? (void
*)&speling_module : NULL);
+ set_module_config(server_conf, &speling_module, arg ? (void *)
&speling_module : NULL);
return NULL;
}
static command_rec speling_cmds[] =
{
{"CheckSpelling", set_speling, NULL, RSRC_CONF, FLAG,
- "whether or not to fix miscapitalized/misspelled requests"},
+ "whether or not to fix miscapitalized/misspelled requests"},
{NULL}
};
@@ -128,7 +128,7 @@
typedef struct {
const char *name;
sp_reason quality;
-} misspelled_file;
+} misspelled_file;
/*
* spdist() is taken from Kernighan & Pike,
@@ -163,7 +163,7 @@
return SP_SIMPLETYPO; /* 1 char mismatch */
}
if (strcasecmp(s + 1, t) == 0)
- return SP_EXTRACHAR;/* extra character */
+ return SP_EXTRACHAR; /* extra character */
}
if (*t && strcasecmp(s, t + 1) == 0)
return SP_MISSINGCHAR; /* missing character */
@@ -173,7 +173,7 @@
static int sort_by_quality(const void *left, const void *rite)
{
return (int) (((misspelled_file *) left)->quality)
- - (int) (((misspelled_file *) rite)->quality);
+ - (int) (((misspelled_file *) rite)->quality);
}
static int check_speling(request_rec *r)
@@ -205,11 +205,12 @@
* r->uri: /correct-url/mispelling/more
* r->filename: /correct-file/mispelling r->path_info: /more
*
- * So we do this in steps. First break r->filename into two peices
+ * So we do this in steps. First break r->filename into two pieces
*/
filoc = rind(r->filename, '/');
- if (filoc == -1)
+ /* Don't do anything if the request doesn't contain a slash, or requests
"/" */
+ if (filoc == -1 || strcmp(r->uri, "/") == 0)
return DECLINED;
/* good = /correct-file */
@@ -240,7 +241,7 @@
if (dotloc == -1)
dotloc = strlen(bad);
- while ((dir_entry = readdir(dirp))) {
+ while ((dir_entry = readdir(dirp)) != NULL) {
sp_reason q;
/*
@@ -328,10 +329,8 @@
/*
* Conditions for immediate redirection:
* a) the first candidate was not found by stripping the suffix
- * AND b) there exists only one candidate OR the best match is not
ambigous
- *
- * Otherwise, a "[300] Multiple Choices" list with the variants is
- * returned.
+ * AND b) there exists only one candidate OR the best match is not
ambigous
+ * then return a redirection right away.
*/
if (variant[0].quality != SP_VERYDIFFERENT &&
(candidates->nelts == 1 || variant[0].quality !=
variant[1].quality)) {
@@ -342,7 +341,7 @@
table_set(r->headers_out, "Location",
construct_url(r->pool, nuri, r->server));
- aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, r->server,
+ aplog_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r->server,
ref ? "Fixed spelling: %s to %s from %s"
: "Fixed spelling: %s to %s",
r->uri, nuri, ref);
@@ -367,17 +366,22 @@
notes = r->main->notes;
}
- /* Generate the reponse text. */
- t = pstrcat(p, "The document name you requested (<code>",
- r->uri, "</code>) could not be found on this server.\n"
- "However, we found documents with names similar to
the one you requested.<p>"
- "Available documents:\n<ul>\n", NULL);
+ /* Generate the response text. */
+ /* Since the text is expanded by repeated calls of
+ * t = pstrcat(p, t, ".."), we can avoid a little waste
+ * of memory by adding the header AFTER building the list.
+ * XXX: FIXME: find a way to build a string concatenation
+ * without repeatedly requesting new memory
+ * XXX: FIXME: Limit the list to a maximum number of entries
+ */
+ t = "";
for (i = 0; i < candidates->nelts; ++i) {
/* The format isn't very neat... */
- t = pstrcat(p, t, "<li><a href=\"", variant[i].name, "\">",
- variant[i].name, "</a> (",
+ t = pstrcat(p, t, "<li><a href=\"", url,
+ variant[i].name, r->path_info, "\">",
+ variant[i].name, r->path_info, "</a> (",
sp_reason_str[(int) (variant[i].quality)], ")\n", NULL);
/*
@@ -393,7 +397,10 @@
t = pstrcat(p, t, "</ul>\nFurthermore, the following
related documents were found:\n<ul>\n", NULL);
}
}
- t = pstrcat(p, t, "</ul>\n", NULL);
+ t = pstrcat(p, "The document name you requested (<code>",
+ r->uri, "</code>) could not be found on this server.\n"
+ "However, we found documents with names similar to
the one you requested.<p>"
+ "Available documents:\n<ul>\n", t, "</ul>\n", NULL);
/* If we know there was a referring page, add a note: */
if (ref != NULL)
@@ -403,7 +410,7 @@
/* Pass our table to http_protocol.c (see mod_negotiation): */
table_set(notes, "variant-list", t);
- aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_INFO, r->server,
+ aplog_error(APLOG_MARK, APLOG_NOERRNO | APLOG_INFO, r->server,
ref ? "Spelling fix: %s: %d candidates from %s"
: "Spelling fix: %s: %d candidates",
r->uri, candidates->nelts, ref);
@@ -415,7 +422,8 @@
return OK;
}
-module MODULE_VAR_EXPORT speling_module = {
+module MODULE_VAR_EXPORT speling_module =
+{
STANDARD_MODULE_STUFF,
NULL, /* initializer */
NULL, /* create per-dir config */