From e0a6f42ec323fbb306d307e386a989b9be78e7be Mon Sep 17 00:00:00 2001 From: Nick Kew Date: Mon, 21 Dec 2009 23:43:50 +0000 Subject: [PATCH] mod_autoindex: support XHTML as equivalent to HTML in IndexOptions, ScanHTMLTitles, ReadmeName, HeaderName PR 48416 [Dmitry Bakshaev , Nick Kew] git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@893035 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ modules/generators/mod_autoindex.c | 17 +++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CHANGES b/CHANGES index 27deb020bd..59942cda21 100644 --- a/CHANGES +++ b/CHANGES @@ -26,6 +26,10 @@ Changes with Apache 2.3.5 check at startup. PR 41887 [Jan van den Berg ] + *) mod_autoindex: support XHTML as equivalent to HTML in IndexOptions, + ScanHTMLTitles, ReadmeName, HeaderName + PR 48416 [Dmitry Bakshaev , Nick Kew] + Changes with Apache 2.3.4 *) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex, diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index ea0e3f99fb..7756f9e415 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -149,6 +149,14 @@ static char c_by_encoding, c_by_type, c_by_path; #define BY_TYPE &c_by_type #define BY_PATH &c_by_path +static inline int response_is_html(request_rec *r) +{ + char *ctype = ap_field_noparam(r->pool, r->content_type); + ap_str_tolower(ctype); + return !strcmp(ctype, "text/html") + || !strcmp(ctype, "application/xhtml+xml"); +} + /* * This routine puts the standard HTML header at the top of the index page. * We include the DOCTYPE because we may be using features therefrom (i.e., @@ -1013,8 +1021,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, * SSIs. */ if (rr->content_type != NULL) { - if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type), - "text/html")) { + if (response_is_html(rr)) { ap_filter_t *f; /* Hope everything will work... */ emit_amble = 0; @@ -1124,8 +1131,7 @@ static void emit_tail(request_rec *r, char *readme_fname, int suppress_amble) * SSIs. */ if (rr->content_type != NULL) { - if (!strcasecmp(ap_field_noparam(r->pool, rr->content_type), - "text/html")) { + if (response_is_html(rr)) { ap_filter_t *f; for (f=rr->output_filters; f->frec != ap_subreq_core_filter_handle; f = f->next); @@ -1175,8 +1181,7 @@ static char *find_title(request_rec *r) return NULL; } if ((r->content_type != NULL) - && (!strcasecmp(ap_field_noparam(r->pool, r->content_type), - "text/html") + && (response_is_html(r) || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE)) && !r->content_encoding) { if (apr_file_open(&thefile, r->filename, APR_READ, -- 2.40.0