Test whether the CssAbsoluteFilter correctly handles spaces in urls, ref #736

This commit is contained in:
Johannes Linke
2016-10-30 18:13:59 +01:00
parent ef861c1694
commit 8fc4f8634c
3 changed files with 19 additions and 4 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

View File

@@ -339,6 +339,21 @@ p { filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='%(compress_u
filter = CssAbsoluteFilter(content)
self.assertEqual(path, filter.guess_filename(url))
def test_filenames_with_space(self):
filename = os.path.join(settings.COMPRESS_ROOT, 'css/url/test.css')
imagefilename = os.path.join(settings.COMPRESS_ROOT, 'img/add with spaces.png')
template = "p { background: url('%(url)simg/add with spaces.png%(query)s%(hash)s%(frag)s') }"
content = template % blankdict(url='../../')
params = blankdict({
'url': settings.COMPRESS_URL,
'hash': '?' + self.hashing_func(imagefilename),
})
output = template % params
filter = CssAbsoluteFilter(content)
self.assertEqual(output, filter.input(filename=filename, basename='css/url/test.css'))
@override_settings(COMPRESS_URL='http://static.example.com/')
class CssAbsolutizingTestCaseWithDifferentURL(CssAbsolutizingTestCase):

View File

@@ -24,8 +24,8 @@ class TestMtimeCacheCommand(TestCase):
call_command(
'mtime_cache', '--add', *self.default_ignore(), stdout=out)
output = out.getvalue()
self.assertIn('Deleted mtimes of 19 files from the cache.', output)
self.assertIn('Added mtimes of 19 files to cache.', output)
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
self.assertIn('Added mtimes of 20 files to cache.', output)
def test_handle_clean(self):
out = StringIO()
@@ -33,5 +33,5 @@ class TestMtimeCacheCommand(TestCase):
call_command(
'mtime_cache', '--clean', *self.default_ignore(), stdout=out)
output = out.getvalue()
self.assertIn('Deleted mtimes of 19 files from the cache.', output)
self.assertNotIn('Added mtimes of 19 files to cache.', output)
self.assertIn('Deleted mtimes of 20 files from the cache.', output)
self.assertNotIn('Added mtimes of 20 files to cache.', output)