diff --git a/certbot-apache/certbot_apache/configurator.py b/certbot-apache/certbot_apache/configurator.py index abe3edede..02602ace6 100644 --- a/certbot-apache/certbot_apache/configurator.py +++ b/certbot-apache/certbot_apache/configurator.py @@ -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: diff --git a/certbot-apache/certbot_apache/tests/configurator_test.py b/certbot-apache/certbot_apache/tests/configurator_test.py index f8bf7676c..dc953174e 100644 --- a/certbot-apache/certbot_apache/tests/configurator_test.py +++ b/certbot-apache/certbot_apache/tests/configurator_test.py @@ -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):