Added check for /files/

This commit is contained in:
Joona Hoikkala 2016-08-10 10:39:10 +03:00
parent 51191c2ea5
commit 14f3710250
No known key found for this signature in database
GPG key ID: C14AAE0F5ADCB854
2 changed files with 8 additions and 2 deletions

View file

@ -1806,9 +1806,14 @@ def get_file_path(vhost_path):
"""
# Strip off /files/
try:
avail_fp = vhost_path[7:].split("/")
except TypeError:
if vhost_path.startswith("/files/"):
avail_fp = vhost_path[7:].split("/")
else:
return None
except AttributeError:
# If we recieved a None path
return None
last_good = ""
# Loop through the path parts and validate after every addition
for p in avail_fp:

View file

@ -128,6 +128,7 @@ class MultipleVhostsTest(util.ApacheTest):
def test_get_bad_path(self):
from certbot_apache.configurator import get_file_path
self.assertEqual(get_file_path(None), None)
self.assertEqual(get_file_path("nonexistent"), None)
self.assertEqual(self.config._create_vhost("nonexistent"), None) # pylint: disable=protected-access
def test_bad_servername_alias(self):