mirror of
https://github.com/certbot/certbot.git
synced 2026-06-08 08:12:15 -04:00
Reject domains with only one label
This commit is contained in:
parent
275e3f748e
commit
307b2e5307
3 changed files with 11 additions and 3 deletions
|
|
@ -66,8 +66,8 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
|
||||
names = self.config.get_all_names()
|
||||
self.assertEqual(names, set(
|
||||
["somename", "another.alias", "alias", "localhost",
|
||||
"155.225.50.69.nephoscale.net", "www.example.org", "myhost"]))
|
||||
["155.225.50.69.nephoscale.net",
|
||||
"www.example.org", "another.alias"]))
|
||||
|
||||
def test_supported_enhancements(self):
|
||||
self.assertEqual(['redirect'], self.config.supported_enhancements())
|
||||
|
|
|
|||
|
|
@ -351,6 +351,9 @@ class EnforceLeValidity(unittest.TestCase):
|
|||
self.assertRaises(
|
||||
errors.ConfigurationError, self._call, u"a-.example.com")
|
||||
|
||||
def test_one_label(self):
|
||||
self.assertRaises(errors.ConfigurationError, self._call, u"com")
|
||||
|
||||
def test_valid_domain(self):
|
||||
self.assertEqual(self._call(u"example.com"), u"example.com")
|
||||
|
||||
|
|
|
|||
|
|
@ -406,7 +406,12 @@ def enforce_le_validity(domain):
|
|||
raise errors.ConfigurationError(
|
||||
"{0} contains an invalid character. "
|
||||
"Valid characters are A-Z, a-z, 0-9, ., and -.".format(domain))
|
||||
for label in domain.split("."):
|
||||
|
||||
labels = domain.split(".")
|
||||
if len(labels) < 2:
|
||||
raise errors.ConfigurationError(
|
||||
"{0} needs at least two labels".format(domain))
|
||||
for label in labels:
|
||||
if label.startswith("-"):
|
||||
raise errors.ConfigurationError(
|
||||
'label "{0}" in domain "{1}" cannot start with "-"'.format(
|
||||
|
|
|
|||
Loading…
Reference in a new issue