httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jason S. Clary" <jcl...@futurefx.com>
Subject crlf patch for mod_include.c
Date Fri, 10 Jan 1997 01:15:05 GMT

The following is the patch I mentioned before.. Its rather insignificant.. It
adds
a <!--#config crlf="on|off" --> directive to ssi.. I've been using it for
quite
some time.  I followed your example with the inclusion of xssi and got rid of
the global variable I had..  If this keeps up we will need a flags structure
that can
be passed to everything.. ;P

All this does is allow you to turn off the output of \n and \r's in your HTML.
 I
use this to make my horizontal button bars on http://www.futurefx.com/ work
properly on netscape and MSIE.. netscape is picky about crlf's in the middle
of a series of <IMG> tags and it puts in a space.. if its all on one line no
spaces it works ok but thats a total pain in the butt to maintain if you use
an editor like joe.. ;P  It just basicly lets you beautify your HTML code by
putting things neatly on multiple lines without messing up the look.  MSIE
could care less about line breaks between images as it touches them together
either way.

The other use is just making it a total pain for anyone to steal bits from
your code.
Think about it, you've got a 5k web page with no line breaks.. anywhere.. 
Thats
going to realy make a poor plagerist cringe.. ;P  I don't do this, mind you..
I just
use it for the button bars..  I'm not that mean.. ;)

Well, if anyone wants it, its here.  Hope it works, I'm still running 1.1.1 on
my server and I just quickly ported this over to 1.2b4.  It does compile, but
I didn't have any way to test it since my config files will bomb with 1.2b4
without
adding a bunch of patches back into it.

which reminds me, Apache needs a -i command line option to make it ignore
unknown config directives.. ;P  For those of us who play..  Maybe have it warn
but
not quit loading...  Course, I could always just use the # character.. 

=== Cut Here ===

--- mod_include.c.orig	Thu Jan  9 16:59:00 1997
+++ mod_include.c	Thu Jan  9 16:59:18 1997
@@ -129,7 +129,7 @@
  * matter much, but this is an inner loop...
  */
 
-int find_string(FILE *in,char *str, request_rec *r, int printing) {
+int find_string(FILE *in,char *str, request_rec *r, int printing, int
sendcrlf) {
     int x,l=strlen(str),p;
     char c;
 
@@ -143,9 +143,11 @@
         else {
             if (printing) {
                 for(x=0;x<p;x++) {
-                    rputc(str[x],r);
+                    if(!((!sendcrlf) && ((str[x] == '\n') || (str[x] ==
'\r'))))
+                      rputc(str[x],r);
                 }
-                rputc(c,r);
+                if(!((!sendcrlf) && ((str[x] == '\n') || (str[x] == '\r'))))
+                  rputc(c,r);
             }
             p=0;
         }
@@ -654,7 +656,7 @@
 }
 
 int handle_config(FILE *in, request_rec *r, char *error, char *tf,
-                  int *sizefmt) {
+                  int *sizefmt, int *sendcrlf) {
     char tag[MAX_STRING_LEN];
     char *tag_val;
     char parsed_string[MAX_STRING_LEN];
@@ -681,7 +683,11 @@
                 *sizefmt = SIZEFMT_BYTES;
             else if(!strcmp(parsed_string,"abbrev"))
                 *sizefmt = SIZEFMT_KMG;
-        } 
+        }
+        else if(!strcmp(tag,"crlf")) {
+          if(!strcasecmp(tag_val, "OFF")) *sendcrlf=0;
+          else *sendcrlf=1;
+        }
         else if(!strcmp(tag,"done"))
             return 0;
         else {
@@ -1536,7 +1542,8 @@
     int if_nesting;
     int printing;
     int conditional_status;
-
+    int sendcrlf;
+    
     strcpy(error,DEFAULT_ERROR_MSG);
     strcpy(timefmt,DEFAULT_TIME_FORMAT);
     sizefmt = SIZEFMT_KMG;
@@ -1545,6 +1552,9 @@
     printing = conditional_status = 1;
     if_nesting = 0;
 
+/*  Turn CRLF on */
+    sendcrlf = 1;
+    
     chdir_file (r->filename);
     if (r->args) { /* add QUERY stuff to env cause it ain't yet */
         table_set (r->subprocess_env, "QUERY_STRING", r->args);
@@ -1554,7 +1564,7 @@
     }
 
     while(1) {
-        if(!find_string(f,STARTING_SEQUENCE,r,printing)) {
+        if(!find_string(f,STARTING_SEQUENCE,r,printing,sendcrlf)) {
             if(get_directive(f,directive,r->pool))
                 return;
             if(!strcmp(directive,"if")) {
@@ -1588,11 +1598,11 @@
                     log_printf(r->server,"httpd: exec used but not allowed in
%s",
                             r->filename);
                     if (printing) rputs(error, r);
-                    ret = find_string(f,ENDING_SEQUENCE,r,0);
+                    ret = find_string(f,ENDING_SEQUENCE,r,0,0);
                 } else 
                     ret=handle_exec(f, r, error);
             } else if(!strcmp(directive,"config"))
-                ret=handle_config(f, r, error, timefmt, &sizefmt);
+                ret=handle_config(f, r, error, timefmt, &sizefmt, &sendcrlf);
             else if(!strcmp(directive,"set"))
                 ret=handle_set(f, r, error);
             else if(!strcmp(directive,"include"))
@@ -1610,7 +1620,7 @@
                         "httpd: unknown directive %s in parsed doc %s",
                         directive,r->filename);
                 if (printing) rputs(error, r);
-                ret=find_string(f,ENDING_SEQUENCE,r,0);
+                ret=find_string(f,ENDING_SEQUENCE,r,0,0);
             }
             if(ret) {
                 log_printf(r->server,"httpd: premature EOF in parsed file
%s",


Mime
View raw message