]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
- add XHTML doctypes to httpd.h
authorAndré Malo <nd@apache.org>
Sun, 2 Nov 2003 20:37:04 +0000 (20:37 +0000)
committerAndré Malo <nd@apache.org>
Sun, 2 Nov 2003 20:37:04 +0000 (20:37 +0000)
- fix the (x)html output of mod_autoindex to be consistent
  and make it configurable to emit either HTML or XHTML

PR: 23747

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@101683 13f79535-47bb-0310-9956-ffa450edef68

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

diff --git a/CHANGES b/CHANGES
index c8991878f6a4e342ca94a2bedcc2031511d602f9..412b843bfc812be4bf7dd49b1aaec264a0a1049d 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,6 +2,12 @@ Changes with Apache 2.1.0-dev
 
   [Remove entries to the current 2.0 section below, when backported]
 
+  *) 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_setenvif: Fix the regex optimizer, which under circumstances
      treated the supplied regex as literal string. PR 24219.
      [André Malo]
index d24492ae6767697114d9f7d7c54afc5f8d9bfd30..ef5d0aa1215cd7ae916df95a7dea030ec2235fda 100644 (file)
  * 20030213.1 (2.1.0-dev) changed log_writer optional fn's to return previous
  *                        handler
  * 20030821 (2.1.0-dev) bumped mod_include's entire API
+ * 20030821.1 (2.1.0-dev) added XHTML doctypes
  */
 
 #define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20030821
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a
index 7512e93ba6bd2f45bcb0467034e201fff1c79b18..a52f9a02853e74a39a862214e1e7714f7420ee68 100644 (file)
@@ -275,6 +275,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 a56e00bfc5834816bf5180cce64dd50fad86f1ff..d2fd5c178a402cd742af20be1815edfecfdd53ba 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);
@@ -1545,7 +1549,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);
@@ -1577,7 +1585,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);
     }
@@ -1593,7 +1602,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);
@@ -1621,7 +1634,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);
@@ -1667,7 +1684,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);
@@ -1753,7 +1774,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);
@@ -1820,7 +1845,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);
@@ -2111,7 +2140,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