From 7f460bcf72e743c4cda32e44a26eb3a07dc54853 Mon Sep 17 00:00:00 2001 From: hno <> Date: Thu, 24 May 2007 03:07:43 +0000 Subject: [PATCH] Back out unintentional commit of unrelated url.cc changes --- src/gopher.cc | 4 ++-- src/protos.h | 4 +++- src/url.cc | 34 +++++++++++++++++++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/gopher.cc b/src/gopher.cc index fb778de182..6dd6e779f0 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -1,6 +1,6 @@ /* - * $Id: gopher.cc,v 1.206 2007/05/23 20:59:14 hno Exp $ + * $Id: gopher.cc,v 1.207 2007/05/23 21:07:43 hno Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -248,7 +248,7 @@ gopher_request_parse(const HttpRequest * req, char *type_id, char *request) if (request) { xstrncpy(request, path + 1, MAX_URL); /* convert %xx to char */ - rfc1738_unescape(request); + url_convert_hex(request, 0); } } diff --git a/src/protos.h b/src/protos.h index a1d000f3e2..39e107b54e 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.544 2007/05/23 20:59:14 hno Exp $ + * $Id: protos.h,v 1.545 2007/05/23 21:07:43 hno Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -624,6 +624,8 @@ SQUIDCEXTERN void unlinkdClose(void); SQUIDCEXTERN void unlinkdUnlink(const char *); #endif +SQUIDCEXTERN char *url_convert_hex(char *org_url, int allocate); +SQUIDCEXTERN char *url_escape(const char *url); SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL); SQUIDCEXTERN void urlInitialize(void); SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL); diff --git a/src/url.cc b/src/url.cc index 45b64b94f4..0dc79767f2 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.159 2007/05/23 20:59:14 hno Exp $ + * $Id: url.cc,v 1.160 2007/05/23 21:07:43 hno Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -49,6 +49,38 @@ static const char valid_hostname_chars[] = "0123456789-." ; +/* convert %xx in url string to a character + * Allocate a new string and return a pointer to converted string */ + +char * +url_convert_hex(char *org_url, int allocate) +{ + static char code[] = "00"; + char *url = NULL; + char *s = NULL; + char *t = NULL; + url = allocate ? (char *) xstrdup(org_url) : org_url; + + if ((int) strlen(url) < 3 || !strchr(url, '%')) + return url; + + for (s = t = url; *s; s++) { + if (*s == '%' && *(s + 1) && *(s + 2)) { + code[0] = *(++s); + code[1] = *(++s); + *t++ = (char) strtol(code, NULL, 16); + } else { + *t++ = *s; + } + } + + do { + *t++ = *s; + } while (*s++); + + return url; +} + void urlInitialize(void) { -- 2.47.2