X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=1b2aee86f89733797c03cb35383e3daeceee1291;hp=bfb180c29d8028530673fd1025e69f8b1a3c38d2;hb=9d463432b4e7421b58ea6b6762dbb427e83d9780;hpb=f31652aedd0c6593032a6979a35d4c4151462f09 diff --git a/urlmatch.c b/urlmatch.c index bfb180c2..1b2aee86 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.1 2002/01/17 20:53:46 jongfoster Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.9 2002/04/04 00:36:36 gliptak Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -7,7 +7,7 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.1 2002/01/17 20:53:46 jongfoste * patterns. * * Copyright : Written by and Copyright (C) 2001 the SourceForge - * IJBSWA team. http://ijbswa.sourceforge.net + * Privoxy team. http://www.privoxy.org/ * * Based on the Internet Junkbuster originally written * by and Copyright (C) 1997 Anonymous Coders and @@ -33,6 +33,31 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.1 2002/01/17 20:53:46 jongfoste * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.9 2002/04/04 00:36:36 gliptak + * always use pcre for matching + * + * Revision 1.8 2002/04/03 23:32:47 jongfoster + * Fixing memory leak on error + * + * Revision 1.7 2002/03/26 22:29:55 swa + * we have a new homepage! + * + * Revision 1.6 2002/03/24 13:25:43 swa + * name change related issues + * + * Revision 1.5 2002/03/13 00:27:05 jongfoster + * Killing warnings + * + * Revision 1.4 2002/03/07 03:46:17 oes + * Fixed compiler warnings + * + * Revision 1.3 2002/03/03 14:51:11 oes + * Fixed CLF logging: Added ocmd member for client's request to struct http_request + * + * Revision 1.2 2002/01/21 00:14:09 jongfoster + * Correcting comment style + * Fixing an uninitialized memory bug in create_url_spec() + * * Revision 1.1 2002/01/17 20:53:46 jongfoster * Moving all our URL and URL pattern parsing code to the same file - it * was scattered around in filters.c, loaders.c and parsers.c. @@ -78,19 +103,6 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.1 2002/01/17 20:53:46 jongfoste const char urlmatch_h_rcs[] = URLMATCH_H_VERSION; -/* Fix a problem with Solaris. There should be no effect on other - * platforms. - * Solaris's isspace() is a macro which uses it's argument directly - * as an array index. Therefore we need to make sure that high-bit - * characters generate +ve values, and ideally we also want to make - * the argument match the declared parameter type of "int". - * - * Why did they write a character function that can't take a simple - * "char" argument? Doh! - */ -#define ijb_isupper(__X) isupper((int)(unsigned char)(__X)) -#define ijb_tolower(__X) tolower((int)(unsigned char)(__X)) - /********************************************************************* * @@ -109,6 +121,7 @@ void free_http_request(struct http_request *http) assert(http); freez(http->cmd); + freez(http->ocmd); freez(http->gpc); freez(http->host); freez(http->url); @@ -291,7 +304,7 @@ jb_err parse_http_url(const char * url, */ { char *vec[BUFFER_SIZE]; - int size; + size_t size; char *p; http->dbuffer = strdup(http->host); @@ -600,7 +613,7 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) return JB_ERR_MEMORY; } - if ((p = strchr(buf, '/'))) + if ((p = strchr(buf, '/')) != NULL) { if (NULL == (url->path = strdup(p))) { @@ -615,7 +628,6 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) url->path = NULL; url->pathlen = 0; } -#ifdef REGEX if (url->path) { int errcode; @@ -648,12 +660,12 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) freez(url->spec); freez(url->path); + regfree(url->preg); freez(url->preg); return JB_ERR_PARSE; } } -#endif if ((p = strchr(buf, ':')) == NULL) { url->port = 0; @@ -667,7 +679,7 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) if (buf[0] != '\0') { char *v[150]; - int size; + size_t size; /* Parse domain part */ if (buf[strlen(buf) - 1] == '.') @@ -686,9 +698,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX + regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ return JB_ERR_MEMORY; } @@ -705,9 +716,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX + regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ freez(url->dbuffer); url->dcount = 0; return JB_ERR_MEMORY; @@ -723,9 +733,8 @@ jb_err create_url_spec(struct url_spec * url, const char * buf) { freez(url->spec); freez(url->path); -#ifdef REGEX + regfree(url->preg); freez(url->preg); -#endif /* def REGEX */ freez(url->dbuffer); url->dcount = 0; return JB_ERR_MEMORY; @@ -761,14 +770,11 @@ void free_url_spec(struct url_spec *url) freez(url->dbuffer); freez(url->dvec); freez(url->path); -#ifdef REGEX if (url->preg) { regfree(url->preg); freez(url->preg); } -#endif - } @@ -791,11 +797,7 @@ int url_match(const struct url_spec *pattern, return ((pattern->port == 0) || (pattern->port == url->port)) && ((pattern->dbuffer == NULL) || (domain_match(pattern, url) == 0)) && ((pattern->path == NULL) || -#ifdef REGEX (regexec(pattern->preg, url->path, 0, NULL, 0) == 0) -#else - (strncmp(pattern->path, url->path, pattern->pathlen) == 0) -#endif ); }