X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=75050847868f7dbb8db95f083812180824b07f57;hp=176fdd308f16b1914ea60a231066a573a127e77c;hb=9087ae1aa5ec3738b8f7f473a04019e466b01dfc;hpb=e10b140e837860410ab2b97562b0d919beea4df0 diff --git a/urlmatch.c b/urlmatch.c index 176fdd30..75050847 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.19 2007/09/02 13:42:11 fabiankeil Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.21 2007/12/24 16:34:23 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -33,6 +33,15 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.19 2007/09/02 13:42:11 fabianke * * Revisions : * $Log: urlmatch.c,v $ + * Revision 1.21 2007/12/24 16:34:23 fabiankeil + * Band-aid (and micro-optimization) that makes it less likely to run out of + * stack space with overly-complex path patterns. Probably masks the problem + * reported by Lee in #1856679. Hohoho. + * + * Revision 1.20 2007/09/02 15:31:20 fabiankeil + * Move match_portlist() from filter.c to urlmatch.c. + * It's used for url matching, not for filtering. + * * Revision 1.19 2007/09/02 13:42:11 fabiankeil * - Allow port lists in url patterns. * - Ditch unused url_spec member pathlen. @@ -509,11 +518,10 @@ static int unknown_method(const char *method) */ "VERSION-CONTROL", "REPORT", "CHECKOUT", "CHECKIN", "UNCHECKOUT", "MKWORKSPACE", "UPDATE", "LABEL", "MERGE", "BASELINE-CONTROL", "MKACTIVITY", - NULL }; int i; - for (i = 0; NULL != known_http_methods[i]; i++) + for (i = 0; i < SZ(known_http_methods); i++) { if (0 == strcmpic(method, known_http_methods[i])) { @@ -1019,9 +1027,10 @@ void free_url_spec(struct url_spec *url) int url_match(const struct url_spec *pattern, const struct http_request *url) { - int port_matches; - int domain_matches; - int path_matches; + /* XXX: these should probably be functions. */ +#define PORT_MATCHES ((NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port)) +#define DOMAIN_MATCHES ((NULL == pattern->dbuffer) || (0 == domain_match(pattern, url))) +#define PATH_MATCHES ((NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0))) if (pattern->tag_regex != NULL) { @@ -1029,11 +1038,7 @@ int url_match(const struct url_spec *pattern, return 0; } - port_matches = (NULL == pattern->port_list) || match_portlist(pattern->port_list, url->port); - domain_matches = (NULL == pattern->dbuffer) || (0 == domain_match(pattern, url)); - path_matches = (NULL == pattern->path) || (0 == regexec(pattern->preg, url->path, 0, NULL, 0)); - - return (port_matches && domain_matches && path_matches); + return (PORT_MATCHES && DOMAIN_MATCHES && PATH_MATCHES); }