---------------------
PatchSet 10246
Date: 2007/12/15 05:17:57
Author: adri
Branch: s27_adri
Tag: (none)
Log:
html_quote() now takes a len parameter and doesn't expect a NUL terminated string;
convert the code over to use this.
Members:
include/util.h:1.17.20.1->1.17.20.2
lib/html_quote.c:1.4->1.4.58.1
src/errorpage.c:1.37.6.1.4.1->1.37.6.1.4.2
src/ftp.c:1.44.4.2.4.4->1.44.4.2.4.5
src/gopher.c:1.26.12.2->1.26.12.3
Index: squid/include/util.h
===================================================================
RCS file: /cvsroot/squid-sf//squid/include/util.h,v
retrieving revision 1.17.20.1
retrieving revision 1.17.20.2
diff -u -r1.17.20.1 -r1.17.20.2
--- squid/include/util.h 14 Dec 2007 06:11:26 -0000 1.17.20.1
+++ squid/include/util.h 15 Dec 2007 05:17:57 -0000 1.17.20.2
@@ -1,5 +1,5 @@
/*
- * $Id: util.h,v 1.17.20.1 2007/12/14 06:11:26 adri Exp $
+ * $Id: util.h,v 1.17.20.2 2007/12/15 05:17:57 adri Exp $
*
* AUTHOR: Harvest Derived
*
@@ -84,7 +84,7 @@
extern void rfc1738_unescape(char *);
/* html.c */
-extern char *html_quote(const char *);
+extern char *html_quote(const char *, int);
#if XMALLOC_STATISTICS
extern void malloc_statistics(void (*)(int, int, int, void *), void *);
Index: squid/lib/html_quote.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/lib/html_quote.c,v
retrieving revision 1.4
retrieving revision 1.4.58.1
diff -u -r1.4 -r1.4.58.1
--- squid/lib/html_quote.c 28 Apr 2006 11:10:49 -0000 1.4
+++ squid/lib/html_quote.c 15 Dec 2007 05:17:57 -0000 1.4.58.1
@@ -81,23 +81,23 @@
* string.
*/
char *
-html_quote(const char *string)
+html_quote(const char *string, int len)
{
static char *buf;
static size_t bufsize = 0;
const char *src;
char *dst;
- int i;
+ int i, j;
/* XXX This really should be implemented using a MemPool, but
* MemPools are not yet available in lib...
*/
- if (buf == NULL || strlen(string) * 6 > bufsize) {
+ if (buf == NULL || len * 6 > bufsize) {
xfree(buf);
- bufsize = strlen(string) * 6 + 1;
+ bufsize = len * 6 + 1;
buf = xcalloc(bufsize, 1);
}
- for (src = string, dst = buf; *src; src++) {
+ for (j = 0, src = string, dst = buf; j < len; j++, src++) {
const char *escape = NULL;
const unsigned char ch = *src;
Index: squid/src/errorpage.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/errorpage.c,v
retrieving revision 1.37.6.1.4.1
retrieving revision 1.37.6.1.4.2
diff -u -r1.37.6.1.4.1 -r1.37.6.1.4.2
--- squid/src/errorpage.c 13 Dec 2007 14:17:52 -0000 1.37.6.1.4.1
+++ squid/src/errorpage.c 15 Dec 2007 05:17:57 -0000 1.37.6.1.4.2
@@ -1,6 +1,6 @@
/*
- * $Id: errorpage.c,v 1.37.6.1.4.1 2007/12/13 14:17:52 adri Exp $
+ * $Id: errorpage.c,v 1.37.6.1.4.2 2007/12/15 05:17:57 adri Exp $
*
* DEBUG: section 4 Error Generation
* AUTHOR: Duane Wessels
@@ -616,7 +616,7 @@
assert(p);
debug(4, 3) ("errorConvert: %%%c --> '%s'\n", token, p);
if (do_quote)
- p = html_quote(p);
+ p = html_quote(p, strlen(p));
return p;
}
Index: squid/src/ftp.c
===================================================================
RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v
retrieving revision 1.44.4.2.4.4
retrieving revision 1.44.4.2.4.5
diff -u -r1.44.4.2.4.4 -r1.44.4.2.4.5
--- squid/src/ftp.c 14 Dec 2007 02:48:36 -0000 1.44.4.2.4.4
+++ squid/src/ftp.c 15 Dec 2007 05:17:57 -0000 1.44.4.2.4.5
@@ -1,6 +1,6 @@
/*
- * $Id: ftp.c,v 1.44.4.2.4.4 2007/12/14 02:48:36 adri Exp $
+ * $Id: ftp.c,v 1.44.4.2.4.5 2007/12/15 05:17:57 adri Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
@@ -369,19 +369,19 @@
{
char *t = xstrdup(title);
rfc1738_unescape(t);
- storeAppendPrintf(e, "FTP Directory: %s\n", html_quote(t));
+ storeAppendPrintf(e, "FTP Directory: %s\n", html_quote(t, strlen(t)));
xfree(t);
}
storeAppendPrintf(e, "\n");
storeAppendPrintf(e, "\n");
if (ftpState->flags.use_base)
storeAppendPrintf(e, "
\n"); for (w = ftpState->cwd_message; w; w = w->next) - storeAppendPrintf(e, "%s\n", html_quote(w->key)); + storeAppendPrintf(e, "%s\n", html_quote(w->key, strlen(w->key))); storeAppendPrintf(e, "\n"); storeAppendPrintf(e, "
This is a searchable Gopher index. Use the search\n" @@ -302,7 +302,7 @@ return; } if (gopherState->conversion == HTML_CSO_PAGE) { - char *html_url = html_quote(storeUrl(entry)); + char *html_url = html_quote(storeUrl(entry), strlen(storeUrl(entry))); gopherHTMLHeader(entry, "CSO Search of %s", html_url); storeAppendPrintf(entry, "
A CSO database usually contains a phonebook or\n" @@ -476,23 +476,23 @@ if (strlen(escaped_selector) != 0) snprintf(tmpbuf, TEMP_BUF_SIZE, " %s\n", icon_url, escaped_selector, rfc1738_escape_part(host), - *port ? ":" : "", port, html_quote(name)); + *port ? ":" : "", port, html_quote(name, strlen(name))); else snprintf(tmpbuf, TEMP_BUF_SIZE, " %s\n", icon_url, rfc1738_escape_part(host), *port ? ":" : "", - port, html_quote(name)); + port, html_quote(name, strlen(name))); } else if (gtype == GOPHER_INFO) { - snprintf(tmpbuf, TEMP_BUF_SIZE, "\t%s\n", html_quote(name)); + snprintf(tmpbuf, TEMP_BUF_SIZE, "\t%s\n", html_quote(name, strlen(name))); } else { if (strncmp(selector, "GET /", 5) == 0) { /* WWW link */ snprintf(tmpbuf, TEMP_BUF_SIZE, " %s\n", - icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name)); + icon_url, host, rfc1738_escape_unescaped(selector + 5), html_quote(name, strlen(name))); } else { /* Standard link */ snprintf(tmpbuf, TEMP_BUF_SIZE, " %s\n", - icon_url, host, gtype, rfc1738_escape(selector), html_quote(name)); + icon_url, host, gtype, rfc1738_escape(selector), html_quote(name, strlen(name))); } } safe_free(escaped_selector); @@ -528,10 +528,10 @@ break; if (gopherState->cso_recno != recno) { - snprintf(tmpbuf, TEMP_BUF_SIZE, "
", recno, html_quote(result)); + snprintf(tmpbuf, TEMP_BUF_SIZE, "
", recno, html_quote(result, strlen(result))); gopherState->cso_recno = recno; } else { - snprintf(tmpbuf, TEMP_BUF_SIZE, "%s\n", html_quote(result)); + snprintf(tmpbuf, TEMP_BUF_SIZE, "%s\n", html_quote(result, strlen(result))); } strCat(outbuf, tmpbuf); break; @@ -559,7 +559,7 @@ case 502: /* Too Many Matches */ { /* Print the message the server returns */ - snprintf(tmpbuf, TEMP_BUF_SIZE, "
", html_quote(result)); + snprintf(tmpbuf, TEMP_BUF_SIZE, "
", html_quote(result, strlen(result))); strCat(outbuf, tmpbuf); break; }