Commit d8c9f036 authored by Markus Legner's avatar Markus Legner

Disallow bare pages domain as custom domain

parent 71f3a88c
......@@ -245,8 +245,8 @@ class PagesDomain < ApplicationRecord
def validate_pages_domain
return unless domain
if domain.downcase.ends_with?(".#{Settings.pages.host.downcase}")
self.errors.add(:domain, "*.#{Settings.pages.host} is restricted. Please compare our documentation at https://docs.gitlab.com/ee/administration/pages/#advanced-configuration against your configuration.")
if domain.downcase.ends_with?(".#{Settings.pages.host.downcase}") || domain.casecmp(Settings.pages.host) == 0
self.errors.add(:domain, "#{Settings.pages.host} and its subdomains cannot be used as custom pages domains. Please compare our documentation at https://docs.gitlab.com/ee/administration/pages/#advanced-configuration against your configuration.")
end
end
......
......@@ -36,9 +36,9 @@ RSpec.describe PagesDomain do
'123.456.789' => true,
'0x12345.com' => true,
'0123123' => true,
'reserved.com' => true,
'a-reserved.com' => true,
'a.b-reserved.com' => true,
'reserved.com' => false,
'_foo.com' => false,
'a.reserved.com' => false,
'a.b.reserved.com' => false,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment