Published in <sxsznzabirr.fsf@florida.munich.redhat.com>.
+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
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));
}
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
".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;
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)
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
{
if (backward)
{
- if (match_tail (s, *accepts))
+ if (match_tail (s, *accepts, 0))
return 1;
}
else
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 *));