Lines 202-213
Link Here
|
202 |
if ((type == BY_PATH) && (!ap_is_matchexp(to))) { |
202 |
if ((type == BY_PATH) && (!ap_is_matchexp(to))) { |
203 |
p->apply_to = apr_pstrcat(arr->pool, "*", to, NULL); |
203 |
p->apply_to = apr_pstrcat(arr->pool, "*", to, NULL); |
204 |
} |
204 |
} |
205 |
else if (to) { |
205 |
else { /* to will never be NULL*/ |
206 |
p->apply_to = apr_pstrdup(arr->pool, to); |
206 |
p->apply_to = apr_pstrdup(arr->pool, to); |
207 |
} |
207 |
} |
208 |
else { |
|
|
209 |
p->apply_to = NULL; |
210 |
} |
211 |
} |
208 |
} |
212 |
|
209 |
|
213 |
static const char *add_alt(cmd_parms *cmd, void *d, const char *alt, |
210 |
static const char *add_alt(cmd_parms *cmd, void *d, const char *alt, |
Lines 755-799
Link Here
|
755 |
const char *content_type = ap_field_noparam(r->pool, r->content_type); |
752 |
const char *content_type = ap_field_noparam(r->pool, r->content_type); |
756 |
const char *content_encoding = r->content_encoding; |
753 |
const char *content_encoding = r->content_encoding; |
757 |
char *path = r->filename; |
754 |
char *path = r->filename; |
|
|
755 |
int is_special = path[0] == '^' ? 1 : 0; /*^^DIRECTORY^^ and ^^BLANKICON^^*/ |
758 |
|
756 |
|
|
|
757 |
/* Define our priorities, |
758 |
* P_PATH is the highest one, (AddIcon, AddAlt) followed by |
759 |
* P_ENC used by AddIconByEncoding followed by |
760 |
* P_TYPE used by AddIconByType |
761 |
* |
762 |
* for e.g we let a match by ENC be overridden by TYPE if both are defined. |
763 |
*/ |
764 |
|
765 |
enum {P_TYPE=1, P_ENC=2, P_PATH=3}; |
766 |
int selected_priority = 0; |
767 |
char *selected = NULL; |
768 |
|
759 |
struct item *items = (struct item *) list->elts; |
769 |
struct item *items = (struct item *) list->elts; |
760 |
int i; |
770 |
int i; |
761 |
|
771 |
|
762 |
for (i = 0; i < list->nelts; ++i) { |
772 |
for (i = 0; i < list->nelts; ++i) { |
763 |
struct item *p = &items[i]; |
773 |
struct item *p = &items[i]; |
764 |
|
774 |
|
765 |
/* Special cased for ^^DIRECTORY^^ and ^^BLANKICON^^ */ |
775 |
/* Special case: Check for header|readme etc that dont have apply_to */ |
766 |
if ((path[0] == '^') || (!ap_strcmp_match(path, p->apply_path))) { |
776 |
if (!*(p->apply_to)) return p->data; |
767 |
if (!*(p->apply_to)) { |
777 |
|
|
|
778 |
/* Verify that this directive applies to the current directory. */ |
779 |
if (!is_special && ap_strcmp_match(path, p->apply_path)) { |
780 |
/* continue if we dont match apply_path and we are not one of the |
781 |
* specials ^^DIRECTORY^^ and ^^BLANKICON^^ |
782 |
*/ |
783 |
continue; |
784 |
} |
785 |
|
786 |
/* Does this element apply to the item? */ |
787 |
if (path_only && (p->type != BY_PATH)) continue; |
788 |
|
789 |
/* We have p->apply_to == ^^DIRECTORY^^ | ^^BLANKICON^^ |
790 |
* only through AddIcon and AddAlt directives which |
791 |
* has p->type == BY_PATH |
792 |
* thus checking for both is redundant. |
793 |
* |
794 |
* The priority is used this way, Each time we match a directive by means |
795 |
* of its apply_to, we set the priority to atleast that directive's so that |
796 |
* no other directive of that type or lower priority is processed again, but |
797 |
* leave the door open for a higher priority directive. |
798 |
*/ |
799 |
if (p->type == BY_PATH) { |
800 |
if (!ap_strcmp_match(path, p->apply_to)) { |
801 |
/* Highest priority. No other directive can override. */ |
768 |
return p->data; |
802 |
return p->data; |
769 |
} |
803 |
} |
770 |
else if (p->type == BY_PATH || path[0] == '^') { |
804 |
} else if(p->type == BY_ENCODING && (selected_priority < P_ENC)) { |
771 |
if (!ap_strcmp_match(path, p->apply_to)) { |
805 |
if (content_encoding && !ap_strcasecmp_match(content_encoding, p->apply_to)) { |
772 |
return p->data; |
806 |
/* (PATH can override.) */ |
773 |
} |
807 |
selected_priority = P_ENC; |
|
|
808 |
selected = p->data; |
774 |
} |
809 |
} |
775 |
else if (!path_only) { |
810 |
} else if(p->type == BY_TYPE && (selected_priority < P_TYPE)) { |
776 |
if (!content_encoding) { |
811 |
if (content_type && !ap_strcasecmp_match(content_type, p->apply_to)) { |
777 |
if (p->type == BY_TYPE) { |
812 |
/* (PATH and ENC can override.) */ |
778 |
if (content_type |
813 |
selected_priority = P_TYPE; |
779 |
&& !ap_strcasecmp_match(content_type, |
814 |
selected = p->data; |
780 |
p->apply_to)) { |
|
|
781 |
return p->data; |
782 |
} |
783 |
} |
784 |
} |
785 |
else { |
786 |
if (p->type == BY_ENCODING) { |
787 |
if (!ap_strcasecmp_match(content_encoding, |
788 |
p->apply_to)) { |
789 |
return p->data; |
790 |
} |
791 |
} |
792 |
} |
793 |
} |
815 |
} |
794 |
} |
816 |
} |
795 |
} |
817 |
} |
796 |
return NULL; |
818 |
return selected; |
797 |
} |
819 |
} |
798 |
|
820 |
|
799 |
#define find_icon(d,p,t) find_item(p,d->icon_list,t) |
821 |
#define find_icon(d,p,t) find_item(p,d->icon_list,t) |