Skip to content

Commit 0c57041

Browse files
authored
IBX-10283: Added urlAlias $id validation (#617)
1 parent 792307c commit 0c57041

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/lib/Persistence/Legacy/Content/UrlAlias/Handler.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ class Handler implements UrlAliasHandlerInterface
4646
*/
4747
public const MAX_URL_ALIAS_DEPTH_LEVEL = 60;
4848

49+
/**
50+
* Match url alias id in form of `<parentId>-<textMD5>`.
51+
*
52+
* @var string
53+
*/
54+
public const URL_ALIAS_ID_PATTERN = '/^\d+-[a-f0-9]{32}$/';
55+
4956
/**
5057
* UrlAlias Gateway.
5158
*
@@ -620,6 +627,10 @@ public function lookup($url)
620627
*/
621628
public function loadUrlAlias($id)
622629
{
630+
if (!preg_match(self::URL_ALIAS_ID_PATTERN, $id)) {
631+
throw new NotFoundException('URLAlias', $id);
632+
}
633+
623634
list($parentId, $textMD5) = explode('-', $id);
624635
$data = $this->gateway->loadRow((int)$parentId, $textMD5);
625636

0 commit comments

Comments
 (0)