From f2f05af3dce890e7bd8ce944b7993fcd0d784b73 Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Mon, 7 Mar 2011 12:54:35 +0100 Subject: [PATCH] Strip embedded whitespace from URLs given at the commandline or the GUI. --- doc/changelog.txt | 2 ++ linkcheck/gui/__init__.py | 2 +- linkcheck/lc_cgi.py | 2 +- linkchecker | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/doc/changelog.txt b/doc/changelog.txt index 4c5e7ca8..8d73c7e0 100644 --- a/doc/changelog.txt +++ b/doc/changelog.txt @@ -9,6 +9,8 @@ Changes: sending false positive status codes for HEAD requests. - checking: Strip leading and trailing whitespace from URLs and print a warning instead of having errors. + Also all embedded whitespace is stripped from URLs given at the + commandline or the GUI. Closes: SF bug #3196918 diff --git a/linkcheck/gui/__init__.py b/linkcheck/gui/__init__.py index b91746e7..71aa0487 100644 --- a/linkcheck/gui/__init__.py +++ b/linkcheck/gui/__init__.py @@ -262,7 +262,7 @@ Version 2 or later. def get_url (self): """Return URL to check from the urlinput widget.""" - url = unicode(self.urlinput.text()).strip() + url = strformat.stripall(unicode(self.urlinput.text())) if url.startswith(u"www."): url = u"http://%s" % url elif url.startswith(u"ftp."): diff --git a/linkcheck/lc_cgi.py b/linkcheck/lc_cgi.py index b2ee1d83..f4eedb1a 100644 --- a/linkcheck/lc_cgi.py +++ b/linkcheck/lc_cgi.py @@ -77,7 +77,7 @@ def checklink (out=sys.stdout, form=None, env=os.environ): # start checking aggregate = director.get_aggregate(config) get_url_from = checker.get_url_from - url = form["url"].value + url = strformat.stripall(form["url"].value) url_data = get_url_from(url, 0, aggregate) try: add_intern_pattern(url_data, config) diff --git a/linkchecker b/linkchecker index 55a97be6..784c6aed 100755 --- a/linkchecker +++ b/linkchecker @@ -761,7 +761,7 @@ if options.stdin: args.extend(read_stdin_urls()) if args: for url in args: - aggregate_url(aggregate, config, url) + aggregate_url(aggregate, config, strformat.stripall(url)) else: log.warn(LOG_CMDLINE, _("no files or URLs given")) # set up profiling