Skip to content

Commit

Permalink
Strip port numbers from root page domains
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Dec 9, 2020
1 parent bc8447d commit 52e85cd
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core-bundle/src/Resources/contao/dca/tl_page.php
Expand Up @@ -1282,7 +1282,16 @@ public function loadDns($varValue)
*/
public function checkDns($varValue)
{
return Idna::encode(preg_replace('#^(?:[a-z]+://)?([\pN\pL[\].:_-]+).*$#iu', '$1', $varValue));
if (!$varValue)
{
return '';
}

// The first part will match IPv6 addresses in square brackets. The
// second part will match domain names and IPv4 addresses.
preg_match('#(?:^(?:[a-z]+]://)?(\[[0-9a-f:]+]))|(?:^(?:[a-z]+://)?([\pN\pL._-]*))#ui', $varValue, $matches);

return Idna::encode($matches[2] ?? $matches[1]);
}

/**
Expand Down

0 comments on commit 52e85cd

Please sign in to comment.