diff options
author | Thomas E. Dickey <dickey@invisible-island.net> | 2007-05-16 21:51:47 -0400 |
---|---|---|
committer | Thomas E. Dickey <dickey@invisible-island.net> | 2007-05-16 21:51:47 -0400 |
commit | 6d83d9244ac4ac76caf7d43143ba59f99e0a6445 (patch) | |
tree | e04e18b3a3bab85e15547e4017142d91b58f8005 | |
parent | cdf342faa36bbeea0fe2d8519d5b17f4b072f7f6 (diff) | |
download | lynx-snapshots-6d83d9244ac4ac76caf7d43143ba59f99e0a6445.tar.gz |
snapshot of project "lynx", label v2-8-7dev_4f
-rw-r--r-- | CHANGES | 13 | ||||
-rw-r--r-- | WWW/Library/Implementation/HTString.c | 84 |
2 files changed, 84 insertions, 13 deletions
diff --git a/CHANGES b/CHANGES index 3049aaf9..d32242bb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,9 +1,9 @@ --- $LynxId: CHANGES,v 1.215 2007/05/13 23:42:13 tom Exp $ +-- $LynxId: CHANGES,v 1.219 2007/05/16 21:51:47 tom Exp $ =============================================================================== Changes since Lynx 2.8 release =============================================================================== -2007-0?-?? (2.8.7dev.5) +2007-05-17 (2.8.7dev.5) * build/install "en" po file so that GNU gettext LANGUAGE environment variable can find the corresponding English message file (request by Chuck Houpt) -TD * add LYNX_HELPFILE environment variable to allow override of location of the @@ -11,7 +11,8 @@ Changes since Lynx 2.8 release * make install-bin and install-lss makefile rules a little quieter (prompted by discussion by Chuck Houpt and TG) -TD * fix an off-by-one in HText_canScrollDown() and total_pages in GridText.c -TH -* rewrite strcasecomp_asterisk() to support wildcards as in RFC 2818 -TD +* rewrite strcasecomp_asterisk() to support wildcards as in RFC 2818 (prompted + by less-complete Debian patch for #401447, see also #268102) -TD * improve X.509 certificate validation -TG This is tested for OpenSSL, ifdef'd to not break gnutls. Changes: + peer certificate is cached, no need to call SSL_get_peer_certificate() @@ -95,7 +96,7 @@ Changes since Lynx 2.8 release * modify CF_SRAND to recognize the asymmetric variant of arc4random() -TD * updated configure script macros CF_SUBDIR_PATH, CF_XOPEN_SOURCE, CF_X_ATHENA_LIBS, CF_X_TOOLKIT -TD -* updated config.guess, config.sub +* updated config.guess, config.sub -TD 2006-11-14 (2.8.7dev.4) * use RFC-822 encoding for filenames passed via file-upload forms (Debian @@ -2167,8 +2168,8 @@ FreeBSD 4.1, 4.8, NetBSD 1.5, 1.6 and OpenBSD 2.8 (curses/ncurses). * correct order of checks for wrapping in www_search_forward() and www_search_backward(), which would allow an infinite loop if there were no anchors on the current page (report by Frederic L W Meunier) -TD -* add a missing chunk to reverted change of SGML_character() - -NSH <nsh@horae.dti.ne.jp> +* add a missing chunk to reverted change of SGML_character() -NSH + <nsh@horae.dti.ne.jp> 2001-07-07 (2.8.4pre.3) * review/add descriptions of new command-line options in lynx.man, lynx.hlp and diff --git a/WWW/Library/Implementation/HTString.c b/WWW/Library/Implementation/HTString.c index 9728e549..014e7ce7 100644 --- a/WWW/Library/Implementation/HTString.c +++ b/WWW/Library/Implementation/HTString.c @@ -1,5 +1,5 @@ /* - * $LynxId: HTString.c,v 1.48 2007/05/13 19:08:59 tom Exp $ + * $LynxId: HTString.c,v 1.49 2007/05/16 21:44:23 tom Exp $ * * Case-independent string comparison HTString.c * @@ -136,9 +136,21 @@ int strncasecomp(const char *a, #define end_component(p) (*(p) == '.' || *(p) == '\0') +#ifdef DEBUG_ASTERISK +#define SHOW_ASTERISK CTRACE +#else +#define SHOW_ASTERISK(p) /* nothing */ +#endif + +#define SHOW_ASTERISK_NUM(a,b,c) \ + SHOW_ASTERISK((tfp, "test @%d, '%s' vs '%s' (%d)\n", __LINE__, a,b,c)) + +#define SHOW_ASTERISK_TXT(a,b,c) \ + SHOW_ASTERISK((tfp, "test @%d, '%s' vs '%s' %s\n", __LINE__, a,b,c)) + /* * Compare names as described in RFC 2818: ignore case, allow wildcards. - * Return zero on a match, nonzero on mismatch. + * Return zero on a match, nonzero on mismatch -TD * * From RFC 2818: * Names may contain the wildcard character * which is considered to match any @@ -149,25 +161,45 @@ int strcasecomp_asterisk(const char *a, const char *b) { const char *p; int result = 0; + int done = FALSE; - while (!result && *a != '\0' && *b != '\0') { + while (!result && !done) { + SHOW_ASTERISK_TXT(a, b, "main"); if (*a == '*') { p = b; - ++a; for (;;) { - if (strcasecomp_asterisk(a, p) && !end_component(p)) { + SHOW_ASTERISK_TXT(a, p, "loop"); + if (end_component(p)) { + if (end_component(a + 1)) { + b = p - 1; + result = 0; + } else { + result = 1; + } + break; + } else if (strcasecomp_asterisk(a + 1, p)) { ++p; result = 1; /* could not match */ } else { - b = p; - result = 0; /* found a match starting here */ + b = p - 1; + result = 0; /* found a match starting at 'p' */ + done = TRUE; break; } } + SHOW_ASTERISK_NUM(a, b, result); } else if (*b == '*') { result = strcasecomp_asterisk(b, a); + SHOW_ASTERISK_NUM(a, b, result); + done = (result == 0); + } else if (*a == '\0' || *b == '\0') { + result = (*a != *b); + SHOW_ASTERISK_NUM(a, b, result); + break; } else if (TOLOWER(UCH(*a)) != TOLOWER(UCH(*b))) { result = 1; + SHOW_ASTERISK_NUM(a, b, result); + break; } ++a; ++b; @@ -175,6 +207,44 @@ int strcasecomp_asterisk(const char *a, const char *b) return result; } +#ifdef DEBUG_ASTERISK +void mismatch_asterisk(void) +{ + /* *INDENT-OFF* */ + static struct { + const char *a; + const char *b; + int code; + } table[] = { + { "foo.bar", "*.*", 0 }, + { "foo.bar", "*.b*", 0 }, + { "foo.bar", "*.ba*", 0 }, + { "foo.bar", "*.bar*", 0 }, + { "foo.bar", "*.*bar*", 0 }, + { "foo.bar", "*.*.", 1 }, + { "foo.bar", "fo*.b*", 0 }, + { "*oo.bar", "fo*.b*", 0 }, + { "*oo.bar.com", "fo*.b*", 1 }, + { "*oo.bar.com", "fo*.b*m", 1 }, + { "*oo.bar.com", "fo*.b*.c*", 0 }, + }; + /* *INDENT-ON* */ + + unsigned n; + int code; + + CTRACE((tfp, "mismatch_asterisk testing\n")); + for (n = 0; n < TABLESIZE(table); ++n) { + CTRACE((tfp, "-------%d\n", n)); + code = strcasecomp_asterisk(table[n].a, table[n].b); + if (code != table[n].code) { + CTRACE((tfp, "mismatch_asterisk '%s' '%s' got %d, want %d\n", + table[n].a, table[n].b, code, table[n].code)); + } + } +} +#endif + #ifdef NOT_ASCII /* Case-insensitive with ASCII collating sequence |