Commit e47199f1 authored by Etienne Baqué's avatar Etienne Baqué

Merge branch 'fix/validate-custom-pages-domain' into 'master'

Fix check for valid custom pages domains

See merge request gitlab-org/gitlab!77247
parents 64bb3a07 d8c9f036
......@@ -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,12 @@ RSpec.describe PagesDomain do
'123.456.789' => true,
'0x12345.com' => true,
'0123123' => true,
'_foo.com' => false,
'a-reserved.com' => true,
'a.b-reserved.com' => true,
'reserved.com' => false,
'_foo.com' => false,
'a.reserved.com' => false,
'a.b.reserved.com' => false,
nil => false
}.each do |value, validity|
context "domain #{value.inspect} validity" do
......
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