ASF Bugzilla – Attachment 22539 Details for
Bug 44218
mod_autoindex shows the default icon for files with a content encoding, rather than the icon configured for the content type
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
make sure that by encoding can override by type
patch (text/plain), 4.49 KB, created by
rahul
on 2008-09-08 04:51:40 UTC
(
hide
)
Description:
make sure that by encoding can override by type
Filename:
MIME Type:
Creator:
rahul
Created:
2008-09-08 04:51:40 UTC
Size:
4.49 KB
patch
obsolete
>Index: modules/generators/mod_autoindex.c >=================================================================== >--- modules/generators/mod_autoindex.c (revision 692630) >+++ modules/generators/mod_autoindex.c (working copy) >@@ -202,12 +202,9 @@ > if ((type == BY_PATH) && (!ap_is_matchexp(to))) { > p->apply_to = apr_pstrcat(arr->pool, "*", to, NULL); > } >- else if (to) { >+ else { /* to will never be NULL*/ > p->apply_to = apr_pstrdup(arr->pool, to); > } >- else { >- p->apply_to = NULL; >- } > } > > static const char *add_alt(cmd_parms *cmd, void *d, const char *alt, >@@ -755,45 +752,70 @@ > const char *content_type = ap_field_noparam(r->pool, r->content_type); > const char *content_encoding = r->content_encoding; > char *path = r->filename; >+ int is_special = path[0] == '^' ? 1 : 0; /*^^DIRECTORY^^ and ^^BLANKICON^^*/ > >+ /* Define our priorities, >+ * P_PATH is the highest one, (AddIcon, AddAlt) followed by >+ * P_ENC used by AddIconByEncoding followed by >+ * P_TYPE used by AddIconByType >+ * >+ * for e.g we let a match by ENC be overridden by TYPE if both are defined. >+ */ >+ >+ enum {P_TYPE=1, P_ENC=2, P_PATH=3}; >+ int selected_priority = 0; >+ char *selected = NULL; >+ > struct item *items = (struct item *) list->elts; > int i; > > for (i = 0; i < list->nelts; ++i) { > struct item *p = &items[i]; > >- /* Special cased for ^^DIRECTORY^^ and ^^BLANKICON^^ */ >- if ((path[0] == '^') || (!ap_strcmp_match(path, p->apply_path))) { >- if (!*(p->apply_to)) { >+ /* Special case: Check for header|readme etc that dont have apply_to */ >+ if (!*(p->apply_to)) return p->data; >+ >+ /* Verify that this directive applies to the current directory. */ >+ if (!is_special && ap_strcmp_match(path, p->apply_path)) { >+ /* continue if we dont match apply_path and we are not one of the >+ * specials ^^DIRECTORY^^ and ^^BLANKICON^^ >+ */ >+ continue; >+ } >+ >+ /* Does this element apply to the item? */ >+ if (path_only && (p->type != BY_PATH)) continue; >+ >+ /* We have p->apply_to == ^^DIRECTORY^^ | ^^BLANKICON^^ >+ * only through AddIcon and AddAlt directives which >+ * has p->type == BY_PATH >+ * thus checking for both is redundant. >+ * >+ * The priority is used this way, Each time we match a directive by means >+ * of its apply_to, we set the priority to atleast that directive's so that >+ * no other directive of that type or lower priority is processed again, but >+ * leave the door open for a higher priority directive. >+ */ >+ if (p->type == BY_PATH) { >+ if (!ap_strcmp_match(path, p->apply_to)) { >+ /* Highest priority. No other directive can override. */ > return p->data; > } >- else if (p->type == BY_PATH || path[0] == '^') { >- if (!ap_strcmp_match(path, p->apply_to)) { >- return p->data; >- } >+ } else if(p->type == BY_ENCODING && (selected_priority < P_ENC)) { >+ if (content_encoding && !ap_strcasecmp_match(content_encoding, p->apply_to)) { >+ /* (PATH can override.) */ >+ selected_priority = P_ENC; >+ selected = p->data; > } >- else if (!path_only) { >- if (!content_encoding) { >- if (p->type == BY_TYPE) { >- if (content_type >- && !ap_strcasecmp_match(content_type, >- p->apply_to)) { >- return p->data; >- } >- } >- } >- else { >- if (p->type == BY_ENCODING) { >- if (!ap_strcasecmp_match(content_encoding, >- p->apply_to)) { >- return p->data; >- } >- } >- } >+ } else if(p->type == BY_TYPE && (selected_priority < P_TYPE)) { >+ if (content_type && !ap_strcasecmp_match(content_type, p->apply_to)) { >+ /* (PATH and ENC can override.) */ >+ selected_priority = P_TYPE; >+ selected = p->data; > } > } > } >- return NULL; >+ return selected; > } > > #define find_icon(d,p,t) find_item(p,d->icon_list,t)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 44218
:
21379
|
21380
|
22528
| 22539