Re: format strings in deny_info?

2003-06-02 Thread Henrik Nordstrom
mån 2003-06-02 klockan 14.31 skrev Gerard Eviston:

> > In the long run this should probably be using a more expressive format
> > syntax to allow other information than the original URL to be
> > inserted into the redirected URL.
> 
> Can you please take a look at the attached patch - not sure if it's The Right 
> Thing but it adds functionality for extra info in the URL.

Looking reasonable, but data inserted into URLs need to be URL escaped
with rfc1738_escape_part() (not rfc1738_escape) before it is inserted
into the URL or else there will be issues in most uses.. while data
inserted into error pages need to be escaped by rfc1738_escape().

Regards
Henri


-- 
Henrik Nordstrom <[EMAIL PROTECTED]>
MARA Systems AB



Re: format strings in deny_info?

2003-06-02 Thread Gerard Eviston
On Mon, 2 Jun 2003 01:41, Henrik Nordstrom wrote:
> On Sunday 01 June 2003 14.29, Gerard Eviston wrote:
> > deny_info allows format strings in urls when redirection is
> > happening. This might be a silly question, but is this intended?
>
> The support for %s is intentional. See the deny_info documentation.
> What is not intentional is that other % codes are also intercepted..
> (minor issue).

At best it was a poorly phrased question :-)

> In the long run this should probably be using a more expressive format
> syntax to allow other information than the original URL to be
> inserted into the redirected URL.

Can you please take a look at the attached patch - not sure if it's The Right 
Thing but it adds functionality for extra info in the URL.

Thanks
Gerard
diff -uNr squid-3.0.DEVEL-20030601/src/cf.data.pre squid-3.0.DEVEL-20030601.new/src/cf.data.pre
--- squid-3.0.DEVEL-20030601/src/cf.data.pre	2003-05-30 01:54:07.0 +1000
+++ squid-3.0.DEVEL-20030601.new/src/cf.data.pre	2003-06-02 22:16:38.0 +1000
@@ -2881,8 +2881,13 @@
 	and put them into the configured errors/ directory.
 
 	Alternatively you can specify an error URL. The browsers will then
-	get redirected (302) to the specified URL. %s in the redirection
-	URL will be replaced by the requested URL.
+	get redirected (302) to the specified URL. Placeholders such as %U
+	can be used in the error URL to include extra information.
+	
+	See the Squid FAQ section on Customizable Error Messages
+	(http://www.squid-cache.org/Doc/FAQ/FAQ-19.html#custom-err-msgs)
+	for more information on placeholders that can be used in ERR_ pages
+	and error URLs.
 
 	Alternatively you can tell Squid to reset the TCP connection
 	by specifying TCP_RESET.
diff -uNr squid-3.0.DEVEL-20030601/src/errorpage.cc squid-3.0.DEVEL-20030601.new/src/errorpage.cc
--- squid-3.0.DEVEL-20030601/src/errorpage.cc	2003-03-10 14:56:38.0 +1000
+++ squid-3.0.DEVEL-20030601.new/src/errorpage.cc	2003-06-02 21:47:53.0 +1000
@@ -101,9 +101,9 @@
 static const char *errorFindHardText(err_type type);
 static ErrorDynamicPageInfo *errorDynamicPageInfoCreate(int id, const char *page_name);
 static void errorDynamicPageInfoDestroy(ErrorDynamicPageInfo * info);
-static MemBuf errorBuildContent(ErrorState * err);
+static MemBuf errorBuildContent(ErrorState * err, int buildUrl = 0);
 static int errorDump(ErrorState * err, MemBuf * mb);
-static const char *errorConvert(char token, ErrorState * err);
+static const char *errorConvert(char token, ErrorState * err, int do_quote = 1);
 static CWCB errorSendComplete;
 
 
@@ -590,12 +590,11 @@
  */
 
 static const char *
-errorConvert(char token, ErrorState * err)
+errorConvert(char token, ErrorState * err, int do_quote)
 {
 request_t *r = err->request;
 static MemBuf mb = MemBufNULL;
 const char *p = NULL;	/* takes priority over mb if set */
-int do_quote = 1;
 
 memBufReset(&mb);
 
@@ -826,10 +825,12 @@
 
 if (strchr(name, ':')) {
 /* Redirection */
-char *quoted_url = rfc1738_escape_part(errorConvert('u', err));
+MemBuf redirectUrl;
+redirectUrl = errorBuildContent(err, true);
 httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, squid_curtime);
-httpHeaderPutStrf(&rep->header, HDR_LOCATION, name, quoted_url);
+httpHeaderPutStr(&rep->header, HDR_LOCATION, rfc1738_escape(redirectUrl.buf));
 httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%d %s\n", err->httpStatus, "Access Denied");
+memBufClean(&redirectUrl);
 } else {
 MemBuf content = errorBuildContent(err);
 httpReplySetHeaders(rep, version, err->httpStatus, NULL, "text/html", content.size, 0, squid_curtime);
@@ -851,7 +852,7 @@
 }
 
 static MemBuf
-errorBuildContent(ErrorState * err)
+errorBuildContent(ErrorState * err, int buildUrl)
 {
 MemBuf content;
 const char *m;
@@ -860,14 +861,14 @@
 assert(err != NULL);
 assert(err->page_id > ERR_NONE && err->page_id < error_page_count);
 memBufDefInit(&content);
-m = error_text[err->page_id];
+m = buildUrl ? errorPageName(err->page_id) : error_text[err->page_id]; 
 assert(m);
 
 while ((p = strchr(m, '%'))) {
 memBufAppend(&content, m, p - m);	/* copy */
-t = errorConvert(*++p, err);	/* convert */
+t = errorConvert(*++p, err, buildUrl ? 0 : 1);	/* convert */
 memBufPrintf(&content, "%s", t);	/* copy */
-m = p + 1;		/* advance */
+m = p + 1;/* advance */
 }
 
 if (*m)


Christian Kunst - Squid iCAP Client

2003-06-02 Thread Christian Kunst
Hi,

My name is Christian Kunst, and I would like to join the Squid team. I am interested 
in helping develop the Squid iCAP client. Please let me know what are the next steps 
that I should take.

Thank you and best regards,

Christian Kunst.


Re: format strings in deny_info?

2003-06-02 Thread Henrik Nordstrom
On Sunday 01 June 2003 14.29, Gerard Eviston wrote:

> deny_info allows format strings in urls when redirection is
> happening. This might be a silly question, but is this intended?

The support for %s is intentional. See the deny_info documentation. 
What is not intentional is that other % codes are also intercepted.. 
(minor issue).

In the long run this should probably be using a more expressive format 
syntax to allow other information than the original URL to be 
inserted into the redirected URL.

Regards
Henrik


Re: Patch for correctly detecting fd_mask

2003-06-02 Thread Henrik Nordstrom
On Sunday 01 June 2003 08.11, Gerard Eviston wrote:
> The proper type for fd_mask may not be detected by configure if
> sys/select.h is not listed in SQUID_DEFAULT_INCLUDES. Can you
> please review the attached patch?

Thanks. Applied.

Regards
Henrik