From 02a54e9919538821a8cd5f8bfb09303e039ac62b Mon Sep 17 00:00:00 2001 From: micah Date: Wed, 29 Aug 2007 21:36:30 -0700 Subject: [PATCH] [svn] Fix #20811: Assertion failure with --spider --recursive. --- src/ChangeLog | 6 ++++++ src/spider.c | 2 +- src/url.c | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 6165534e..74b58e4e 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -38,6 +38,12 @@ RETRUNNEEDED appears never to be referenced outside of http.c (and wget.h), and, when returned by gethttp, is translated by http_loop to RETROK. + * url.c (are_urls_equal): Don't call getchar_from_escaped_string + if u2 is shorter than u1. + (test_are_urls_equal): Added tests to handle u2 shorter than u1, + and %2f not treated the same as / (latter currently fails). + * spider.c (in_url_list_p): Don't call are_urls_equal if one of + them is NULL. 2007-08-23 Joshua David Williams diff --git a/src/spider.c b/src/spider.c index 183d8d2b..b0bda64c 100644 --- a/src/spider.c +++ b/src/spider.c @@ -74,7 +74,7 @@ in_url_list_p (const struct url_list *list, const char *url) for (ptr = list; ptr; ptr = ptr->next) { /* str[case]cmp is inadequate for URL comparison */ - if (are_urls_equal (url, ptr->url)) + if (ptr->url != NULL && are_urls_equal (url, ptr->url)) return true; } diff --git a/src/url.c b/src/url.c index 04ecb3a4..683a7745 100644 --- a/src/url.c +++ b/src/url.c @@ -1971,11 +1971,12 @@ are_urls_equal (const char *u1, const char *u2) const char *p, *q; int pp, qq; char ch1, ch2; + assert(u1 && u2); p = u1; q = u2; - while (*p + while (*p && *q && (pp = getchar_from_escaped_string (p, &ch1)) && (qq = getchar_from_escaped_string (q, &ch2)) && (TOLOWER(ch1) == TOLOWER(ch2))) @@ -2111,6 +2112,8 @@ test_are_urls_equal() { "http://www.adomain.com/apath/", "http://www.adomain.com/anotherpath/", false }, { "http://www.adomain.com/apath/", "http://www.anotherdomain.com/path/", false }, { "http://www.adomain.com/~path/", "http://www.adomain.com/%7epath/", true }, + { "http://www.adomain.com/longer-path/", "http://www.adomain.com/path/", false }, + { "http://www.adomain.com/path%2f", "http://www.adomain.com/path/", false }, }; for (i = 0; i < sizeof(test_array)/sizeof(test_array[0]); ++i) -- 2.39.2