httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ben Laurie <...@gonzo.ben.algroup.co.uk>
Subject Re: # in file names...
Date Sun, 01 Oct 1995 17:12:29 GMT
> 
> > > [# in a directory index]
> 
> Ok, how about:
> 
> 	% touch "foo^V^Mbar"		ie foo, ctrl-M, bar
> 
> This produces a file that:
> 
> a)	looks like sh*t on the screen

Well, some kind of escaping needs to be done for the text, too. That could
take a little more discussion than fixing the URI.

> b)	can't be found when you click on the link
> c)	is a valid UNIX file
> 
> There are probably others when you get into doing odd things with
> control characters.
> 
> Ay.

Hmmm ... good point. OK, here's a new improved patch (if someone with The Power
could put it in the patches dir, please):

From: ben@algroup.co.uk (Ben Laurie)
Subject: Escape URIs more correctly
Affects: util.c
Changelog: Apache failed to convert # to %23 in directory listings, and various
other dodgy characters.

*** ../../apache_0.8.14/src/util.c	Tue Sep 19 17:05:00 1995
--- util.c	Sun Oct  1 18:01:37 1995
***************
*** 463,476 ****
      }
  }
  
! #define c2x(what,where) sprintf(where,"%%%2x",what)
  
  char *escape_uri(pool *p, char *uri) {
      register int x,y;
      char *copy = palloc (p, 3 * strlen (uri) + 1);
              
      for(x=0,y=0; uri[x]; x++,y++) {
!         if (ind (":% ?+&",(copy[y] = uri[x])) != -1) {
              c2x(uri[x],&copy[y]);
              y+=2;
          }
--- 463,476 ----
      }
  }
  
! #define c2x(what,where) sprintf(where,"%%%02x",what)
  
  char *escape_uri(pool *p, char *uri) {
      register int x,y;
      char *copy = palloc (p, 3 * strlen (uri) + 1);
              
      for(x=0,y=0; uri[x]; x++,y++) {
!         if (ind (":% ?+&#",(copy[y] = uri[x])) != -1 || uri[x] < 0x20 || uri[x] >
0x7e) {
              c2x(uri[x],&copy[y]);
              y+=2;
          }

-- 
Ben Laurie                  Phone: +44 (181) 994 6435
Freelance Consultant        Fax:   +44 (181) 994 6472
and Technical Director      Email: ben@algroup.co.uk
A.L. Digital Ltd,
London, England.

Mime
View raw message