httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rob Hartill <r...@imdb.com>
Subject 1.2b7 directory handling fix: SuppressHTMLPreamble addition (fwd)
Date Wed, 26 Feb 1997 02:24:03 GMT

I've a feeling this has already been fixed.

---------- Forwarded message ----------
Date: Wed, 26 Feb 1997 04:49:03 +0300 (MSK)
From: "[KOI8-R] áÎÄÒÅÊ þÅÒÎÏ×" <ache@nagual.ru>
To: apache-bugs@apache.org
Subject: 1.2b7 directory handling fix: SuppressHTMLPreamble addition

Situation:

Currently it is impossible to suppress initial HTML preamble for
directories, i.e.  

<HTML><HEAD>\n<TITLE>Index of dir</TITLE>\n</HEAD><BODY>


It means that it is impossible to change <TITLE> or add any <META
HTTP-EQUIV...> tags to <HEAD> section or change <BODY> attributes (f.e.
background) without HTML syntax violation (.asis, cern_meta, etc. not
helps here too).

Fix:

I add "SuppressHTMLPreamble" option to "IndexOptions". When this option is
set _and_ HEADER.html (or what you set as header) is present, readable and
HTML file, standard <HTML><HEAD>\n<TITLE>Index... preamble will be
suppressed assuming you have right HTML preamble in your HEADER.html. It
solves all problems mentioned above. 

This patch related to 1.2b7, please include it in future releases:

*** src/mod_dir.c.orig	Tue Feb 18 17:41:29 1997
--- src/mod_dir.c	Wed Feb 26 03:46:28 1997
***************
*** 81,86 ****
--- 81,87 ----
  #define SUPPRESS_LAST_MOD 8
  #define SUPPRESS_SIZE 16
  #define SUPPRESS_DESC 32
+ #define SUPPRESS_HTML_PREAMBLE 64
  
  struct item {
      char *type;
***************
*** 203,208 ****
--- 204,211 ----
              opts |= SUPPRESS_SIZE;
          else if(!strcasecmp(w,"SuppressDescription"))
              opts |= SUPPRESS_DESC;
+ 	else if(!strcasecmp(w,"SuppressHTMLPreamble"))
+ 	    opts |= SUPPRESS_HTML_PREAMBLE;
          else if(!strcasecmp(w,"None"))
              opts = 0;
  	else
***************
*** 402,409 ****
   * Actually generating output
   */
  
  
! int insert_readme(char *name, char *readme_fname, int rule, request_rec *r) {
      char *fn;
      FILE *f;
      struct stat finfo;
--- 405,425 ----
   * Actually generating output
   */
  
+ void put_html_preamble(char *title_name, request_rec *r)
+ {
+     rvputs
+ 	(
+ 	    r,
+ 	    "<HTML><HEAD>\n<TITLE>Index of ",
+ 	    title_name,
+ 	    "</TITLE>\n</HEAD><BODY>\n",
+ 	    NULL
+ 	);
+ }
  
! int insert_readme(char *name, char *readme_fname, int rule,
! 		  char *title_name, request_rec *r)
! {
      char *fn;
      FILE *f;
      struct stat finfo;
***************
*** 417,428 ****
          if(stat(fn,&finfo) == -1)
              return 0;
          plaintext=1;
-         if(rule) rputs("<HR>\n", r);
-         rputs("<PRE>\n", r);
      }
-     else if (rule) rputs("<HR>\n", r);
      if(!(f = pfopen(r->pool,fn,"r")))
          return 0;
      if (!plaintext)
  	send_fd(f, r);
      else
--- 433,446 ----
          if(stat(fn,&finfo) == -1)
              return 0;
          plaintext=1;
      }
      if(!(f = pfopen(r->pool,fn,"r")))
          return 0;
+     if(!rule && plaintext && title_name != NULL)
+ 	put_html_preamble(title_name, r);
+     if(rule) rputs("<HR>\n", r);
+     if(plaintext) rputs("<PRE>\n", r);
+ 
      if (!plaintext)
  	send_fd(f, r);
      else
***************
*** 715,731 ****
      while (title_endp > title_name && *title_endp == '/')
  	*title_endp-- = '\0';
      
!     rvputs
! 	(
! 	    r,
! 	    "<HTML><HEAD>\n<TITLE>Index of ",
! 	    title_name,
! 	    "</TITLE>\n</HEAD><BODY>\n",
! 	    NULL
! 	);
  
!     if((!(tmp = find_header(dir_conf,r))) || (!(insert_readme(name,tmp,0,r))))
          rvputs(r, "<H1>Index of ", title_name, "</H1>\n", NULL);
  
      /* 
       * Since we don't know how many dir. entries there are, put them into a 
--- 733,750 ----
      while (title_endp > title_name && *title_endp == '/')
  	*title_endp-- = '\0';
      
!     if(!(dir_opts & SUPPRESS_HTML_PREAMBLE))
! 	put_html_preamble(title_name, r);
  
!     if((!(tmp = find_header(dir_conf,r))) ||
!        (!(insert_readme(name, tmp, 0,
! 			((dir_opts & SUPPRESS_HTML_PREAMBLE) ?
! 			title_name : NULL), r))))
!     {
! 	if(dir_opts & SUPPRESS_HTML_PREAMBLE)
! 	    put_html_preamble(title_name, r);
          rvputs(r, "<H1>Index of ", title_name, "</H1>\n", NULL);
+     }
  
      /* 
       * Since we don't know how many dir. entries there are, put them into a 
***************
*** 760,766 ****
  
      if (dir_opts & FANCY_INDEXING)
          if((tmp = find_readme(dir_conf, r)))
!             insert_readme(name,tmp,1,r);
      else {
          rputs("</UL>", r);
      }
--- 779,785 ----
  
      if (dir_opts & FANCY_INDEXING)
          if((tmp = find_readme(dir_conf, r)))
!             insert_readme(name,tmp,1,NULL,r);
      else {
          rputs("</UL>", r);
      }



-- 
Andrey A. Chernov
<ache@null.net>
http://www.nagual.ru/~ache/




Mime
View raw message