Detect filenames with spaces as internal links.

This commit is contained in:
Bastian Kleineidam 2010-12-21 07:05:12 +01:00
parent 9ea35241c0
commit 90e0f4e5cc
4 changed files with 21 additions and 10 deletions

View file

@ -3,6 +3,8 @@
Fixes:
- checking: Fix broken anchor checking.
Closes: SF bug #3140765
- checking: Properly detect filenames with spaces as
internal links when given as start URL.
- logging: Allow Unicode strings to be written to stdout without
encoding errors.
- gui: Reset statistics before each run.

View file

@ -266,14 +266,6 @@ class FileUrl (urlbase.UrlBase):
@return non-empty regex pattern or None
@rtype String or None
"""
url = absolute_url(self.base_url, self.base_ref, self.parent_url)
if not url:
if not self.url:
return None
parts = strformat.url_unicode_split(url)
path = urlutil.splitparams(parts[2])[0]
segments = path.split('/')
if not self.is_directory():
# cut off filename to have a directory
segments = segments[:-1]
path = "/".join(segments)
return "file://%s" % re.escape(path)
return re.escape(self.url)

View file

@ -0,0 +1 @@

View file

@ -129,3 +129,19 @@ class TestFile (LinkCheckTest):
u"valid",
]
self.direct(url, resultlines)
def test_good_dir_space (self):
url = u"file://%(curdir)s/%(datadir)s/a b/" % self.get_attrs()
nurl = self.norm(url)
resultlines = [
u"url %s" % url,
u"cache key %s" % nurl,
u"real url %s" % nurl,
u"valid",
u"url t.txt",
u"cache key %st.txt" % nurl,
u"real url %st.txt" % nurl,
u"name t.txt",
u"valid",
]
self.direct(url, resultlines, recursionlevel=1)