Skip to content

Commit

Permalink
[Bug]: Fix Site Additional domain validation issues (pimcore#17698)
Browse files Browse the repository at this point in the history
  • Loading branch information
kingjia90 authored Oct 8, 2024
1 parent 0a3bd0d commit 1d1c3e1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions models/Site.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,14 +229,17 @@ public function setDomains(array|string $domains): static
if (is_string($domains)) {
$domains = Serialize::unserialize($domains);
}
array_map(static function ($domain) {
//replace all wildcards with a placeholder dummy string
$wildCardLessDomain = str_replace('*', 'anystring', $domain);
if (!filter_var($wildCardLessDomain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
throw new InvalidArgumentException(sprintf('Invalid domain name "%s"', $domain));
}
}, $domains);
$this->domains = $domains;
if (is_array($domains)) {
$domains = array_filter($domains);
array_map(static function ($domain) {
//replace all wildcards with a placeholder dummy string
$wildCardLessDomain = str_replace('*', 'anystring', $domain);
if ($wildCardLessDomain && !filter_var($wildCardLessDomain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
throw new InvalidArgumentException(sprintf('Invalid domain name "%s"', $domain));
}
}, $domains);
$this->domains = $domains;
}

return $this;
}
Expand Down

0 comments on commit 1d1c3e1

Please sign in to comment.