httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marc Slemko <ma...@znep.com>
Subject 1.2.1 directory handling patch: SuppressHTMLPreamble addition (fwd)
Date Mon, 14 Jul 1997 21:49:47 GMT
Ken, are you working on mod_autoindex?

---------- Forwarded message ----------
Date: Tue, 15 Jul 1997 01:38:45 +0400 (MSD)
From: "[KOI8-R] Андрей Чернов" <ache@nagual.pp.ru>
To: "Roy T. Fielding" <fielding@kiwi.ICS.UCI.EDU>
Cc: new-httpd@hyperreal.org, apache-bugs@apache.org, marcs@znep.com
Subject: 1.2.1 directory handling patch: SuppressHTMLPreamble addition

On Tue, 25 Feb 1997, Roy T. Fielding wrote:

> >I've a feeling this has already been fixed.
>
> That's because I already proposed a (better) patch for it, based on
> his earlier patch, back in December.  It didn't make the feature freeze,
> so it will just have to wait until after 1.2 is final.  The patch is
> in the patch directory on www.apache.org.

I found it in dist/contrib/patches, but it not applies cleanly to
1.2.1 sources due to few small code changes.

To minimize your efforts I cleanup the thing by myself, here the patch which
applies cleanly to 1.2.1, so you can just put it into next beta.

*** src/mod_dir.c.orig	Fri Jun 27 06:21:22 1997
--- src/mod_dir.c	Tue Jul  8 16:12:10 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;
***************
*** 209,214 ****
--- 210,217 ----
              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
***************
*** 409,415 ****
   */
  
  
! int insert_readme(char *name, char *readme_fname, int rule, request_rec *r) {
      char *fn;
      FILE *f;
      struct stat finfo;
--- 412,438 ----
   */
  
  
! static void html_preamble(request_rec *r, const int do_heading)
! {
!     char *title_name = escape_html(r->pool, r->uri);
!     char *title_endp;
! 
!     title_endp = title_name + strlen(title_name) - 1;
! 
!     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 (do_heading)
!         rvputs(r, "<H1>Index of ", title_name, "</H1>\n", NULL);
! }
! 
! 
! int insert_readme(char *name, char *readme_fname, int rule,
!                   int suppress_preamble, request_rec *r)
! {
      char *fn;
      FILE *f;
      struct stat finfo;
***************
*** 425,434 ****
          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);
      /* XXX: when the above is rewritten properly, this necessary security
       * check will be redundant. -djg */
      rr = sub_req_lookup_file (fn, r);
--- 448,454 ----
***************
*** 439,450 ****
      destroy_sub_req (rr);
      if(!(f = pfopen(r->pool,fn,"r")))
          return 0;
!     if (!plaintext)
  	send_fd(f, r);
      else
      {
  	char buf[IOBUFSIZE+1];
  	int i, n, c, ch;
  	while (!feof(f))
  	{
  	    do n = fread(buf, sizeof(char), IOBUFSIZE, f);
--- 459,484 ----
      destroy_sub_req (rr);
      if(!(f = pfopen(r->pool,fn,"r")))
          return 0;
!     if (!plaintext) {
!         if (rule)
!             rputs("<HR>\n", r);      /* README.html file, send separator */
!         else if (!suppress_preamble)
!             html_preamble(r, 0);     /* HEADER.html file, send preamble  */
! 
  	send_fd(f, r);
+     }
      else
      {
  	char buf[IOBUFSIZE+1];
  	int i, n, c, ch;
+ 
+         if (rule)
+             rputs("<HR>\n", r);      /* README.txt file, send separator */
+         else
+             html_preamble(r, 0);     /* HEADER.txt file, send preamble  */
+ 
+         rputs("<PRE>\n", r);
+ 
  	while (!feof(f))
  	{
  	    do n = fread(buf, sizeof(char), IOBUFSIZE, f);
***************
*** 700,709 ****
      
  int index_directory(request_rec *r, dir_config_rec *dir_conf)
  {
-     char *title_name = escape_html(r->pool, r->uri);
-     char *title_endp;
      char *name = r->filename;
-     
      DIR *d;
      struct DIR_TYPE *dstruct;
      int num_ent=0,x;
--- 734,740 ----
***************
*** 727,750 ****
      }
      hard_timeout("send directory", r);
  
!     /* Spew HTML preamble */
!     
!     title_endp = title_name + strlen(title_name) - 1;
! 
!     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 
--- 758,768 ----
      }
      hard_timeout("send directory", r);
  
!     /* Spew HTML preamble and/or HEADER file */
      
!     if (!((tmp = find_header(dir_conf, r)) &&
!           insert_readme(name,tmp,0,(dir_opts & SUPPRESS_HTML_PREAMBLE),r)))
!         html_preamble(r, 1);
  
      /* 
       * Since we don't know how many dir. entries there are, put them into a 
***************
*** 779,785 ****
  
      if (dir_opts & FANCY_INDEXING)
          if((tmp = find_readme(dir_conf, r)))
!             insert_readme(name,tmp,1,r);
      else {
          rputs("</UL>", r);
      }
--- 797,803 ----
  
      if (dir_opts & FANCY_INDEXING)
          if((tmp = find_readme(dir_conf, r)))
!             insert_readme(name,tmp,1,1,r);
      else {
          rputs("</UL>", r);
      }


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


Mime
View raw message