Skip to content

Commit 52e85cd

Browse files
committed
Strip port numbers from root page domains
1 parent bc8447d commit 52e85cd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

core-bundle/src/Resources/contao/dca/tl_page.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,16 @@ public function loadDns($varValue)
12821282
*/
12831283
public function checkDns($varValue)
12841284
{
1285-
return Idna::encode(preg_replace('#^(?:[a-z]+://)?([\pN\pL[\].:_-]+).*$#iu', '$1', $varValue));
1285+
if (!$varValue)
1286+
{
1287+
return '';
1288+
}
1289+
1290+
// The first part will match IPv6 addresses in square brackets. The
1291+
// second part will match domain names and IPv4 addresses.
1292+
preg_match('#(?:^(?:[a-z]+]://)?(\[[0-9a-f:]+]))|(?:^(?:[a-z]+://)?([\pN\pL._-]*))#ui', $varValue, $matches);
1293+
1294+
return Idna::encode($matches[2] ?? $matches[1]);
12861295
}
12871296

12881297
/**

0 commit comments

Comments
 (0)