httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerenkra...@apache.org
Subject cvs commit: httpd-2.0/modules/metadata mod_mime_magic.c
Date Wed, 19 Feb 2003 05:58:02 GMT
jerenkrantz    2003/02/18 21:58:01

  Modified:    .        CHANGES
               modules/metadata mod_mime_magic.c
  Log:
  If mod_mime_magic does not know the content-type, do not attempt to guess.
  
  PR: 16908
  Submitted by:	Andrew Gapon <agapon@telcordia.com>
  Reviewed by:	Justin Erenkrantz
  
  Revision  Changes    Path
  1.1080    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1079
  retrieving revision 1.1080
  diff -u -u -r1.1079 -r1.1080
  --- CHANGES	19 Feb 2003 03:01:20 -0000	1.1079
  +++ CHANGES	19 Feb 2003 05:58:00 -0000	1.1080
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) If mod_mime_magic does not know the content-type, do not attempt to
  +     guess.  PR 16908.  [Andrew Gapon <agapon@telcordia.com>]
  +
     *) Fix apxs to insert LoadModule directives only outside of sections.
        PR 9012.  [André Malo]
   
  
  
  
  1.61      +18 -20    httpd-2.0/modules/metadata/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_mime_magic.c,v
  retrieving revision 1.60
  retrieving revision 1.61
  diff -u -u -r1.60 -r1.61
  --- mod_mime_magic.c	3 Feb 2003 17:53:09 -0000	1.60
  +++ mod_mime_magic.c	19 Feb 2003 05:58:00 -0000	1.61
  @@ -257,7 +257,7 @@
   static int ascmagic(request_rec *, unsigned char *, apr_size_t);
   static int is_tar(unsigned char *, apr_size_t);
   static int softmagic(request_rec *, unsigned char *, apr_size_t);
  -static void tryit(request_rec *, unsigned char *, apr_size_t, int);
  +static int tryit(request_rec *, unsigned char *, apr_size_t, int);
   static int zmagic(request_rec *, unsigned char *, apr_size_t);
   
   static int getvalue(server_rec *, struct magic *, char **);
  @@ -903,11 +903,15 @@
   	return HTTP_INTERNAL_SERVER_ERROR;
       }
   
  -    if (nbytes == 0)
  -	magic_rsl_puts(r, MIME_TEXT_UNKNOWN);
  +    if (nbytes == 0) {
  +        return DECLINED;
  +    }
       else {
   	buf[nbytes++] = '\0';	/* null-terminate it */
  -	tryit(r, buf, nbytes, 1); 
  +        result = tryit(r, buf, nbytes, 1);
  +	if (result != OK) {
  +            return result;
  +        }
       }
   
       (void) apr_file_close(fd);
  @@ -917,32 +921,33 @@
   }
   
   
  -static void tryit(request_rec *r, unsigned char *buf, apr_size_t nb, int checkzmagic)
  +static int tryit(request_rec *r, unsigned char *buf, apr_size_t nb,
  +                 int checkzmagic)
   {
       /*
        * Try compression stuff
        */
   	if (checkzmagic == 1) {  
   			if (zmagic(r, buf, nb) == 1)
  -			return;
  +			return OK;
   	}
   
       /*
        * try tests in /etc/magic (or surrogate magic file)
        */
       if (softmagic(r, buf, nb) == 1)
  -	return;
  +	return OK;
   
       /*
        * try known keywords, check for ascii-ness too.
        */
       if (ascmagic(r, buf, nb) == 1)
  -	return;
  +	return OK;
   
       /*
        * abandon hope, all ye who remain here
        */
  -    magic_rsl_puts(r, MIME_BINARY_UNKNOWN);
  +    return DECLINED;
   }
   
   #define    EATAB {while (apr_isspace(*l))  ++l;}
  @@ -2070,16 +2075,7 @@
       }
   
       /* all else fails, but it is ascii... */
  -    if (has_escapes) {
  -	/* text with escape sequences */
  -	/* we leave this open for further differentiation later */
  -	magic_rsl_puts(r, "text/plain");
  -    }
  -    else {
  -	/* plain text */
  -	magic_rsl_puts(r, "text/plain");
  -    }
  -    return 1;
  +    return 0;
   }
   
   
  @@ -2141,7 +2137,9 @@
   	return 0;
   
       if ((newsize = uncompress(r, i, &newbuf, nbytes)) > 0) {
  -	tryit(r, newbuf, newsize, 0);
  +	if (tryit(r, newbuf, newsize, 0) != OK) {
  +            return 0;
  +        }
   
   	/* set encoding type in the request record */
   	r->content_encoding = compr[i].encoding;
  
  
  

Mime
View raw message