mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
[svn] Allow match_tail to be case insensitive.
Published in <sxsznzabirr.fsf@florida.munich.redhat.com>.
This commit is contained in:
parent
291693c3c2
commit
fd42ae1311
@ -1,3 +1,14 @@
|
||||
2002-05-08 Hrvoje Niksic <hniksic@arsdigita.com>
|
||||
|
||||
* cookies.c (check_domain_match): Use match_tail in case
|
||||
insensitive mode.
|
||||
|
||||
* utils.c (match_tail): Allow the caller to specify case
|
||||
insensitive mode.
|
||||
|
||||
* cookies.c (store_cookie): When expiry_time is 0, print it as
|
||||
undefined, not indefinite.
|
||||
|
||||
2002-05-07 Ian Abbott <abbotti@mev.co.uk>
|
||||
|
||||
* cookies.c (cookie_jar_process_set_cookie): Do not store
|
||||
|
@ -230,7 +230,7 @@ store_cookie (struct cookie_jar *jar, struct cookie *cookie)
|
||||
cookie->permanent ? "permanent" : "nonpermanent",
|
||||
cookie->secure,
|
||||
cookie->expiry_time
|
||||
? asctime (localtime (&cookie->expiry_time)) : "<indefinitely>",
|
||||
? asctime (localtime (&cookie->expiry_time)) : "<undefined>",
|
||||
cookie->attr, cookie->value));
|
||||
}
|
||||
|
||||
@ -676,7 +676,7 @@ check_domain_match (const char *cookie_domain, const char *host)
|
||||
DEBUGP ((" 3"));
|
||||
|
||||
/* HOST must match the tail of cookie_domain. */
|
||||
if (!match_tail (host, cookie_domain))
|
||||
if (!match_tail (host, cookie_domain, 1))
|
||||
return 0;
|
||||
|
||||
/* We know that COOKIE_DOMAIN is a subset of HOST; however, we must
|
||||
@ -754,7 +754,7 @@ check_domain_match (const char *cookie_domain, const char *host)
|
||||
".com", ".edu", ".net", ".org", ".gov", ".mil", ".int"
|
||||
};
|
||||
for (i = 0; i < ARRAY_SIZE (known_toplevel_domains); i++)
|
||||
if (match_tail (cookie_domain, known_toplevel_domains[i]))
|
||||
if (match_tail (cookie_domain, known_toplevel_domains[i], 1))
|
||||
{
|
||||
known_toplevel = 1;
|
||||
break;
|
||||
|
12
src/ftp.c
12
src/ftp.c
@ -698,6 +698,18 @@ Error in server response, closing control connection.\n"));
|
||||
|
||||
if (cmd & DO_RETR)
|
||||
{
|
||||
/* If we're in spider mode, don't really retrieve anything. The
|
||||
fact that we got to this point should be proof enough that
|
||||
the file exists, vaguely akin to HTTP's concept of a "HEAD"
|
||||
request. */
|
||||
if (opt.spider)
|
||||
{
|
||||
CLOSE (csock);
|
||||
closeport (dtsock);
|
||||
rbuf_uninitialize (&con->rbuf);
|
||||
return RETRFINISHED;
|
||||
}
|
||||
|
||||
if (opt.verbose)
|
||||
{
|
||||
if (!opt.server_response)
|
||||
|
37
src/utils.c
37
src/utils.c
@ -755,20 +755,37 @@ accdir (const char *directory, enum accd flags)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Match the end of STRING against PATTERN. For instance:
|
||||
/* Return non-zero if STRING ends with TAIL. For instance:
|
||||
|
||||
match_tail ("abc", "bc", 0) -> 1
|
||||
match_tail ("abc", "ab", 0) -> 0
|
||||
match_tail ("abc", "abc", 0) -> 1
|
||||
|
||||
If FOLD_CASE_P is non-zero, the comparison will be
|
||||
case-insensitive. */
|
||||
|
||||
match_backwards ("abc", "bc") -> 1
|
||||
match_backwards ("abc", "ab") -> 0
|
||||
match_backwards ("abc", "abc") -> 1 */
|
||||
int
|
||||
match_tail (const char *string, const char *pattern)
|
||||
match_tail (const char *string, const char *tail, int fold_case_p)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
for (i = strlen (string), j = strlen (pattern); i >= 0 && j >= 0; i--, j--)
|
||||
if (string[i] != pattern[j])
|
||||
break;
|
||||
/* If the pattern was exhausted, the match was succesful. */
|
||||
/* We want this to be fast, so we code two loops, one with
|
||||
case-folding, one without. */
|
||||
|
||||
if (!fold_case_p)
|
||||
{
|
||||
for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--)
|
||||
if (string[i] != tail[j])
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = strlen (string), j = strlen (tail); i >= 0 && j >= 0; i--, j--)
|
||||
if (TOLOWER (string[i]) != TOLOWER (tail[j]))
|
||||
break;
|
||||
}
|
||||
|
||||
/* If the tail was exhausted, the match was succesful. */
|
||||
if (j == -1)
|
||||
return 1;
|
||||
else
|
||||
@ -797,7 +814,7 @@ in_acclist (const char *const *accepts, const char *s, int backward)
|
||||
{
|
||||
if (backward)
|
||||
{
|
||||
if (match_tail (s, *accepts))
|
||||
if (match_tail (s, *accepts, 0))
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
@ -69,7 +69,7 @@ char *file_merge PARAMS ((const char *, const char *));
|
||||
int acceptable PARAMS ((const char *));
|
||||
int accdir PARAMS ((const char *s, enum accd));
|
||||
char *suffix PARAMS ((const char *s));
|
||||
int match_tail PARAMS ((const char *, const char *));
|
||||
int match_tail PARAMS ((const char *, const char *, int));
|
||||
|
||||
int has_html_suffix_p PARAMS ((const char *));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user