]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
allow switching between xhtml and html
authorAndré Malo <nd@apache.org>
Mon, 12 Jan 2004 15:54:36 +0000 (15:54 +0000)
committerAndré Malo <nd@apache.org>
Mon, 12 Jan 2004 15:54:36 +0000 (15:54 +0000)
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

CHANGES
STATUS
include/ap_mmn.h
include/httpd.h
modules/generators/mod_autoindex.c

diff --git a/CHANGES b/CHANGES
index fc28eb556a5f6402d0eeb6c75ff0b72112538238..64d601699a574c63351cb0ef0dd31a5e49713b24 100644 (file)
--- 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 <seidel apple.com>]
 
diff --git a/STATUS b/STATUS
index f49b746a6d905bcb6aaeec1ab68d5a7d9ec270c6..8c1cc76563e61ba931ad9d13647e9182db311691 100644 (file)
--- 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
index 7d614e5547230c1044bcb2a7cb1079f275647b46..b7e2a96fb67605b746961517949160834684c334 100644 (file)
  * 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" */
 #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
index 95d06c682be37b9cc5d0ca9987097e2431c369e4..3943cea53d290e2280e954799004337f1541d45b 100644 (file)
@@ -280,6 +280,21 @@ extern "C" {
 #define DOCTYPE_HTML_4_0F "<!DOCTYPE HTML PUBLIC \"-//W3C//" \
                           "DTD HTML 4.0 Frameset//EN\"\n" \
                           "\"http://www.w3.org/TR/REC-html40/frameset.dtd\">\n"
+/** XHTML 1.0 Strict Doctype */
+#define DOCTYPE_XHTML_1_0S "<!DOCTYPE html PUBLIC \"-//W3C//" \
+                           "DTD XHTML 1.0 Strict//EN\"\n" \
+                           "\"http://www.w3.org/TR/xhtml1/DTD/" \
+                           "xhtml1-strict.dtd\">\n"
+/** XHTML 1.0 Transitional Doctype */
+#define DOCTYPE_XHTML_1_0T "<!DOCTYPE html PUBLIC \"-//W3C//" \
+                           "DTD XHTML 1.0 Transitional//EN\"\n" \
+                           "\"http://www.w3.org/TR/xhtml1/DTD/" \
+                           "xhtml1-transitional.dtd\">\n"
+/** XHTML 1.0 Frameset Doctype */
+#define DOCTYPE_XHTML_1_0F "<!DOCTYPE html PUBLIC \"-//W3C//" \
+                           "DTD XHTML 1.0 Frameset//EN\"\n" \
+                           "\"http://www.w3.org/TR/xhtml1/DTD/" \
+                           "xhtml1-frameset.dtd\">"
 
 /** Internal representation for a HTTP protocol number, e.g., HTTP/1.1 */
 
index 9142680ea630f92a2e5956085d85646c0bac7c9f..920412d32f213dfbcb71e4fc2a1cd67d11e691a2 100644 (file)
@@ -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,
               "<html>\n <head>\n  <title>Index of ", title,
               "</title>\n </head>\n <body>\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, "<h1>Index of ", title, "</h1>\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(" /></th>", r);
+
+                if (autoindex_opts & EMIT_XHTML) {
+                    ap_rputs(" /", r);
+                }
+                ap_rputs("></th>", r);
             }
             else {
                 ap_rputs("&nbsp;</th>", r);
@@ -1575,7 +1583,8 @@ static void output_directories(struct ent **ar, int n,
         if (!(autoindex_opts & SUPPRESS_RULES)) {
             breakrow = apr_psprintf(r->pool,
                                     "<tr><th colspan=\"%d\">"
-                                    "<hr /></th></tr>\n", cols);
+                                    "<hr%s></th></tr>\n", cols,
+                                    (autoindex_opts & EMIT_XHTML) ? " /" : "");
         }
         ap_rvputs(r, "</th></tr>", 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("<hr />", r);
+            ap_rputs("<hr", r);
+            if (autoindex_opts & EMIT_XHTML) {
+                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("&nbsp;", 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("<hr /></pre>\n", r);
+            ap_rputs("<hr", r);
+            if (autoindex_opts & EMIT_XHTML) {
+                ap_rputs(" /", r);
+            }
+            ap_rputs("></pre>\n", r);
         }
         else {
             ap_rputs("</pre>\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