From: André Malo Date: Mon, 12 Jan 2004 15:54:36 +0000 (+0000) Subject: allow switching between xhtml and html X-Git-Tag: 2.0.49~219 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=79e206e83ca1cef60bd48053fa6145bfb1b10b54;p=thirdparty%2Fapache%2Fhttpd.git allow switching between xhtml and html PR: 23747 Reviewed by: Justin Erenkrantz, Jeff Trawick git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102292 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index fc28eb556a5..64d601699a5 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,11 @@ Changes with Apache 2.0.49 + *) mod_autoindex: Add 'XHTML' option in order to allow switching between + HTML 3.2 and XHTML 1.0 output. PR 23747. [André Malo] + + *) Add XHTML Document Type Definitions to httpd.h (minor MMN bump). + [André Malo] + *) mod_ssl: Advertise SSL library version as determined at run-time rather than at compile-time. PR 23956. [Eric Seidel ] diff --git a/STATUS b/STATUS index f49b746a6d9..8c1cc76563e 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/01/12 14:59:16 $] +Last modified at [$Date: 2004/01/12 15:54:35 $] Release: @@ -282,16 +282,6 @@ PATCHES TO BACKPORT FROM 2.1 modules/metadata/mod_setenvif.c: r1.44 +1: nd, jerenkrantz - * mod_autoindex: Allow switching between XHTML and HTML output. - PR 23747. (minor MMN bump). - modules/generators/mod_autoindex.c: r1.124 - include/httpd.h: r1.201 - include/ap_mmn.h: r1.60 - jerenkrantz suggests: Why don't we just always output XHTML instead? - nd replies: backwards compat; it would break those sites who have html - READMEs or HEADERs (or don't want to use xhtml) - +1: nd, jerenkrantz, trawick - * LDAP cache fixes from Matthieu Estrade; see PR 18756 include/util_ldap.h r1.12 modules/experimental/util_ldap.c r1.15, r1.16 diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 7d614e55472..b7e2a96fb67 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -116,6 +116,7 @@ * 20020903.4 (2.0.47-dev) add ap_is_recursion_limit_exceeded() * 20020903.5 (2.0.49-dev) add ap_escape_errorlog_item() * 20020903.6 (2.0.49-dev) add insert_error_filter hook + * 20020903.7 (2.0.49-dev) added XHTML Doctypes */ #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */ @@ -123,7 +124,7 @@ #ifndef MODULE_MAGIC_NUMBER_MAJOR #define MODULE_MAGIC_NUMBER_MAJOR 20020903 #endif -#define MODULE_MAGIC_NUMBER_MINOR 6 /* 0...n */ +#define MODULE_MAGIC_NUMBER_MINOR 7 /* 0...n */ /** * Determine if the server's current MODULE_MAGIC_NUMBER is at least a diff --git a/include/httpd.h b/include/httpd.h index 95d06c682be..3943cea53d2 100644 --- a/include/httpd.h +++ b/include/httpd.h @@ -280,6 +280,21 @@ extern "C" { #define DOCTYPE_HTML_4_0F "\n" +/** XHTML 1.0 Strict Doctype */ +#define DOCTYPE_XHTML_1_0S "\n" +/** XHTML 1.0 Transitional Doctype */ +#define DOCTYPE_XHTML_1_0T "\n" +/** XHTML 1.0 Frameset Doctype */ +#define DOCTYPE_XHTML_1_0F "" /** Internal representation for a HTTP protocol number, e.g., HTTP/1.1 */ diff --git a/modules/generators/mod_autoindex.c b/modules/generators/mod_autoindex.c index 9142680ea63..920412d32f2 100644 --- a/modules/generators/mod_autoindex.c +++ b/modules/generators/mod_autoindex.c @@ -111,6 +111,7 @@ module AP_MODULE_DECLARE_DATA autoindex_module; #define TABLE_INDEXING (1 << 14) #define IGNORE_CLIENT (1 << 15) #define IGNORE_CASE (1 << 16) +#define EMIT_XHTML (1 << 17) #define K_NOADJUST 0 #define K_ADJUST 1 @@ -190,9 +191,9 @@ static char c_by_encoding, c_by_type, c_by_path; * We include the DOCTYPE because we may be using features therefrom (i.e., * HEIGHT and WIDTH attributes on the icons if we're FancyIndexing). */ -static void emit_preamble(request_rec *r, char *title) +static void emit_preamble(request_rec *r, int xhtml, const char *title) { - ap_rvputs(r, DOCTYPE_HTML_3_2, + ap_rvputs(r, xhtml ? DOCTYPE_XHTML_1_0T : DOCTYPE_HTML_3_2, "\n \n Index of ", title, "\n \n \n", NULL); } @@ -411,6 +412,9 @@ static const char *add_opts(cmd_parms *cmd, void *d, const char *optstr) else if (!strcasecmp(w, "VersionSort")) { option = VERSION_SORT; } + else if (!strcasecmp(w, "XHTML")) { + option = EMIT_XHTML; + } else if (!strcasecmp(w, "None")) { if (action != '\0') { return "Cannot combine '+' or '-' with 'None' keyword"; @@ -989,7 +993,7 @@ static void do_emit_plain(request_rec *r, apr_file_t *f) * oh well. */ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, - char *title) + int emit_xhtml, char *title) { apr_table_t *hdrs = r->headers_in; apr_file_t *f = NULL; @@ -1032,7 +1036,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, emit_H1 = 0; if (! suppress_amble) { - emit_preamble(r, title); + emit_preamble(r, emit_xhtml, title); } /* This is a hack, but I can't find any better way to do this. * The problem is that we have already created the sub-request, @@ -1070,7 +1074,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, */ if (apr_file_open(&f, rr->filename, APR_READ, APR_OS_DEFAULT, r->pool) == APR_SUCCESS) { - emit_preamble(r, title); + emit_preamble(r, emit_xhtml, title); emit_amble = 0; do_emit_plain(r, f); apr_file_close(f); @@ -1092,7 +1096,7 @@ static void emit_head(request_rec *r, char *header_fname, int suppress_amble, } if (emit_amble) { - emit_preamble(r, title); + emit_preamble(r, emit_xhtml, title); } if (emit_H1) { ap_rvputs(r, "

Index of ", title, "

\n", NULL); @@ -1543,7 +1547,11 @@ static void output_directories(struct ent **ar, int n, if (d->icon_height) { ap_rprintf(r, " height=\"%d\"", d->icon_height); } - ap_rputs(" />", r); + + if (autoindex_opts & EMIT_XHTML) { + ap_rputs(" /", r); + } + ap_rputs(">", r); } else { ap_rputs(" ", r); @@ -1575,7 +1583,8 @@ static void output_directories(struct ent **ar, int n, if (!(autoindex_opts & SUPPRESS_RULES)) { breakrow = apr_psprintf(r->pool, "" - "
\n", cols); + "\n", cols, + (autoindex_opts & EMIT_XHTML) ? " /" : ""); } ap_rvputs(r, "", breakrow, NULL); } @@ -1591,7 +1600,11 @@ static void output_directories(struct ent **ar, int n, if (d->icon_height) { ap_rprintf(r, " height=\"%d\"", d->icon_height); } - ap_rputs(" /> ", r); + + if (autoindex_opts & EMIT_XHTML) { + ap_rputs(" /", r); + } + ap_rputs("> ", r); } else { ap_rputs(" ", r); @@ -1619,7 +1632,11 @@ static void output_directories(struct ent **ar, int n, colargs, static_columns); } if (!(autoindex_opts & SUPPRESS_RULES)) { - ap_rputs("
", r); + ap_rputs("", r); } else { ap_rputc('\n', r); @@ -1665,7 +1682,11 @@ static void output_directories(struct ent **ar, int n, if (d->icon_height) { ap_rprintf(r, " height=\"%d\"", d->icon_height); } - ap_rputs(" />", r); + + if (autoindex_opts & EMIT_XHTML) { + ap_rputs(" /", r); + } + ap_rputs(">", r); } else { ap_rputs(" ", r); @@ -1751,7 +1772,11 @@ static void output_directories(struct ent **ar, int n, if (d->icon_height) { ap_rprintf(r, " height=\"%d\"", d->icon_height); } - ap_rputs(" />", r); + + if (autoindex_opts & EMIT_XHTML) { + ap_rputs(" /", r); + } + ap_rputs(">", r); } else { ap_rputs(" ", r); @@ -1818,7 +1843,11 @@ static void output_directories(struct ent **ar, int n, } else if (autoindex_opts & FANCY_INDEXING) { if (!(autoindex_opts & SUPPRESS_RULES)) { - ap_rputs("
\n", r); + ap_rputs("\n", r); } else { ap_rputs("\n", r); @@ -2095,7 +2124,8 @@ static int index_directory(request_rec *r, } emit_head(r, find_header(autoindex_conf, r), - autoindex_opts & SUPPRESS_PREAMBLE, title_name); + autoindex_opts & SUPPRESS_PREAMBLE, + autoindex_opts & EMIT_XHTML, title_name); /* * Since we don't know how many dir. entries there are, put them into a