mirror of
https://github.com/certbot/certbot.git
synced 2026-08-04 16:13:23 +02:00
Reject domains with only one label
This commit is contained in:
@@ -66,8 +66,8 @@ class NginxConfiguratorTest(util.NginxTest):
|
|||||||
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
|
mock_gethostbyaddr.return_value = ('155.225.50.69.nephoscale.net', [], [])
|
||||||
names = self.config.get_all_names()
|
names = self.config.get_all_names()
|
||||||
self.assertEqual(names, set(
|
self.assertEqual(names, set(
|
||||||
["somename", "another.alias", "alias", "localhost",
|
["155.225.50.69.nephoscale.net",
|
||||||
"155.225.50.69.nephoscale.net", "www.example.org", "myhost"]))
|
"www.example.org", "another.alias"]))
|
||||||
|
|
||||||
def test_supported_enhancements(self):
|
def test_supported_enhancements(self):
|
||||||
self.assertEqual(['redirect'], self.config.supported_enhancements())
|
self.assertEqual(['redirect'], self.config.supported_enhancements())
|
||||||
|
|||||||
@@ -351,6 +351,9 @@ class EnforceLeValidity(unittest.TestCase):
|
|||||||
self.assertRaises(
|
self.assertRaises(
|
||||||
errors.ConfigurationError, self._call, u"a-.example.com")
|
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):
|
def test_valid_domain(self):
|
||||||
self.assertEqual(self._call(u"example.com"), u"example.com")
|
self.assertEqual(self._call(u"example.com"), u"example.com")
|
||||||
|
|
||||||
|
|||||||
+6
-1
@@ -406,7 +406,12 @@ def enforce_le_validity(domain):
|
|||||||
raise errors.ConfigurationError(
|
raise errors.ConfigurationError(
|
||||||
"{0} contains an invalid character. "
|
"{0} contains an invalid character. "
|
||||||
"Valid characters are A-Z, a-z, 0-9, ., and -.".format(domain))
|
"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("-"):
|
if label.startswith("-"):
|
||||||
raise errors.ConfigurationError(
|
raise errors.ConfigurationError(
|
||||||
'label "{0}" in domain "{1}" cannot start with "-"'.format(
|
'label "{0}" in domain "{1}" cannot start with "-"'.format(
|
||||||
|
|||||||
Reference in New Issue
Block a user