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

Function make_autoindex_entry

modules/generators/mod_autoindex.c:1302–1416  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1300}
1301
1302static struct ent *make_autoindex_entry(const apr_finfo_t *dirent,
1303 int autoindex_opts,
1304 autoindex_config_rec *d,
1305 request_rec *r, char keyid,
1306 char direction,
1307 const char *pattern)
1308{
1309 request_rec *rr;
1310 struct ent *p;
1311 int show_forbidden = 0;
1312
1313 /* Dot is ignored, Parent is handled by make_parent_entry() */
1314 if ((dirent->name[0] == '.') && (!dirent->name[1]
1315 || ((dirent->name[1] == '.') && !dirent->name[2])))
1316 return (NULL);
1317
1318 /*
1319 * On some platforms, the match must be case-blind. This is really
1320 * a factor of the filesystem involved, but we can't detect that
1321 * reliably - so we have to granularise at the OS level.
1322 */
1323 if (pattern && (apr_fnmatch(pattern, dirent->name,
1324 APR_FNM_NOESCAPE | APR_FNM_PERIOD
1325#ifdef CASE_BLIND_FILESYSTEM
1326 | APR_FNM_CASE_BLIND
1327#endif
1328 )
1329 != APR_SUCCESS)) {
1330 return (NULL);
1331 }
1332
1333 if (ignore_entry(d, ap_make_full_path(r->pool,
1334 r->filename, dirent->name))) {
1335 return (NULL);
1336 }
1337
1338 if (!(rr = ap_sub_req_lookup_dirent(dirent, r, AP_SUBREQ_NO_ARGS, NULL))) {
1339 return (NULL);
1340 }
1341
1342 if ((autoindex_opts & SHOW_FORBIDDEN)
1343 && (rr->status == HTTP_UNAUTHORIZED || rr->status == HTTP_FORBIDDEN)) {
1344 show_forbidden = 1;
1345 }
1346
1347 if ((rr->finfo.filetype != APR_DIR && rr->finfo.filetype != APR_REG)
1348 || !(rr->status == OK || ap_is_HTTP_SUCCESS(rr->status)
1349 || ap_is_HTTP_REDIRECT(rr->status)
1350 || show_forbidden == 1)) {
1351 ap_destroy_sub_req(rr);
1352 return (NULL);
1353 }
1354
1355 p = (struct ent *) apr_pcalloc(r->pool, sizeof(struct ent));
1356 if (dirent->filetype == APR_DIR) {
1357 p->name = apr_pstrcat(r->pool, dirent->name, "/", NULL);
1358 }
1359 else {

Callers 1

index_directoryFunction · 0.85

Calls 7

ignore_entryFunction · 0.85
ap_make_full_pathFunction · 0.85
ap_sub_req_lookup_direntFunction · 0.85
ap_destroy_sub_reqFunction · 0.85
ap_make_dirstr_parentFunction · 0.85
find_descFunction · 0.85
find_titleFunction · 0.85

Tested by

no test coverage detected