X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=blobdiff_plain;f=urlmatch.c;h=ebaf63c1964d0cc9c63a11b1194f2519adbfeb64;hp=b390e353ea782579aa3a5773fdf96ee305d7d28e;hb=f7b5dc65ad09236147cd10027921c7a652d6ccbe;hpb=2bcd3fa6d83fc9c6e96b9d3d8a2d309a18e2e18e diff --git a/urlmatch.c b/urlmatch.c index b390e353..ebaf63c1 100644 --- a/urlmatch.c +++ b/urlmatch.c @@ -1,4 +1,4 @@ -const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.57 2009/06/03 16:44:15 fabiankeil Exp $"; +const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.60 2011/04/19 13:00:47 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/urlmatch.c,v $ @@ -58,7 +58,13 @@ const char urlmatch_rcs[] = "$Id: urlmatch.c,v 1.57 2009/06/03 16:44:15 fabianke const char urlmatch_h_rcs[] = URLMATCH_H_VERSION; -enum regex_anchoring {NO_ANCHORING, LEFT_ANCHORED, RIGHT_ANCHORED}; +enum regex_anchoring +{ + NO_ANCHORING, + LEFT_ANCHORED, + RIGHT_ANCHORED, + RIGHT_ANCHORED_HOST +}; static jb_err compile_host_pattern(struct url_spec *url, const char *host_pattern); /********************************************************************* @@ -546,9 +552,10 @@ jb_err parse_http_request(const char *req, struct http_request *http) * * Parameters : * 1 : pattern = The pattern to compile. - * 2 : anchoring = How the regex should be anchored. - * Can be either one of NO_ANCHORING, - * LEFT_ANCHORED or RIGHT_ANCHORED. + * 2 : anchoring = How the regex should be modified + * before compilation. Can be either + * one of NO_ANCHORING, LEFT_ANCHORED, + * RIGHT_ANCHORED or RIGHT_ANCHORED_HOST. * 3 : url = In case of failures, the spec member is * logged and the structure freed. * 4 : regex = Where the compiled regex should be stored. @@ -582,6 +589,9 @@ static jb_err compile_pattern(const char *pattern, enum regex_anchoring anchorin case RIGHT_ANCHORED: fmt = "%s$"; break; + case RIGHT_ANCHORED_HOST: + fmt = "%s\\.?$"; + break; case LEFT_ANCHORED: fmt = "^%s"; break; @@ -731,7 +741,7 @@ static jb_err compile_url_pattern(struct url_spec *url, char *buf) *********************************************************************/ static jb_err compile_host_pattern(struct url_spec *url, const char *host_pattern) { - return compile_pattern(host_pattern, RIGHT_ANCHORED, url, &url->host_regex); + return compile_pattern(host_pattern, RIGHT_ANCHORED_HOST, url, &url->host_regex); } #else @@ -919,7 +929,7 @@ static int simplematch(const char *pattern, const char *text) || ((*pat == ']') && (charmap[*txt / 8] & (1 << (*txt % 8)))) ) { /* - * Sucess: Go ahead + * Success: Go ahead */ pat++; } @@ -1118,7 +1128,7 @@ jb_err create_url_spec(struct url_spec *url, char *buf) } /* Is it a tag pattern? */ - if (0 == strncmpic("TAG:", url->spec, 4)) + if (0 == strncmpic(url->spec, "TAG:", 4)) { /* The pattern starts with the first character after "TAG:" */ const char *tag_pattern = buf + 4;