Skip to content

Commit 90caa2a

Browse files
leofeyerausi
andauthored
Strip port numbers from root page domains (see contao#2553)
Description ----------- | Q | A | -----------------| --- | Fixed issues | Fixes contao#2214 | Docs PR or issue | - Tested against https://regex101.com/r/jU0OrQ/2 Commits ------- 52e85cd Strip port numbers from root page domains 48a0c3c Improve the regex Co-authored-by: Martin Auswöger <martin@auswoeger.com>
1 parent bc8447d commit 90caa2a

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:]+]|[\pN\pL._-]*)#ui', $varValue, $matches);
1293+
1294+
return Idna::encode($matches[1]);
12861295
}
12871296

12881297
/**

0 commit comments

Comments
 (0)