Skip to content

Commit 34302eb

Browse files
committed
Make sure generated element ID contains only alphanumeric plus dash
1 parent c368aca commit 34302eb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

Util/Block/AbstractRenderer.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,11 @@ protected function setNameInLayout(AbstractBlock $block): void
7171

7272
protected function getUniqId(AbstractBlock $block, array $data = []): string
7373
{
74-
$ancestorId = $this->ancestorBlock->getNameInLayout();
74+
$ancestorId = preg_replace('/([^a-zA-Z0-9\-]+)/', '-', $this->ancestorBlock->getNameInLayout());
7575

7676
if (isset($data['uniq'])) {
77-
return $ancestorId . '-' . $data['uniq'];
77+
$uniq = preg_replace('/([^a-zA-Z0-9\-]+)/', '-', $data['uniq']);
78+
return $ancestorId . '-' . $uniq;
7879
}
7980

8081
$blockParts = explode('.', $block->getNameInLayout());

0 commit comments

Comments
 (0)