MCPcopy Create free account
hub / github.com/apache/httpd / check_speling

Function check_speling

modules/mappers/mod_speling.c:197–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

195}
196
197static int check_speling(request_rec *r)
198{
199 spconfig *cfg;
200 char *good, *bad, *postgood, *url;
201 apr_finfo_t dirent;
202 int filoc, dotloc, urlen, pglen;
203 apr_array_header_t *candidates = NULL;
204 apr_dir_t *dir;
205
206 cfg = ap_get_module_config(r->per_dir_config, &speling_module);
207 if (!cfg->enabled) {
208 return DECLINED;
209 }
210
211 /* We only want to worry about GETs */
212 if (r->method_number != M_GET) {
213 return DECLINED;
214 }
215
216 /* We've already got a file of some kind or another */
217 if (r->finfo.filetype != APR_NOFILE) {
218 return DECLINED;
219 }
220
221 /* Not a file request */
222 if (r->proxyreq || !r->filename) {
223 return DECLINED;
224 }
225
226 /* This is a sub request - don't mess with it */
227 if (r->main) {
228 return DECLINED;
229 }
230
231 /*
232 * The request should end up looking like this:
233 * r->uri: /correct-url/mispelling/more
234 * r->filename: /correct-file/mispelling r->path_info: /more
235 *
236 * So we do this in steps. First break r->filename into two pieces
237 */
238
239 filoc = ap_rind(r->filename, '/');
240 /*
241 * Don't do anything if the request doesn't contain a slash, or
242 * requests "/"
243 */
244 if (filoc == -1 || strcmp(r->uri, "/") == 0) {
245 return DECLINED;
246 }
247
248 /* good = /correct-file */
249 good = apr_pstrndup(r->pool, r->filename, filoc);
250 /* bad = mispelling */
251 bad = apr_pstrdup(r->pool, r->filename + filoc + 1);
252 /* postgood = mispelling/more */
253 postgood = apr_pstrcat(r->pool, bad, r->path_info, NULL);
254

Callers

nothing calls this directly

Calls 5

ap_get_module_configFunction · 0.85
ap_rindFunction · 0.85
ap_indFunction · 0.85
spdistFunction · 0.85
ap_construct_urlFunction · 0.85

Tested by

no test coverage detected