Skip to content

Commit a739e52

Browse files
committed
Merge remote-tracking branch 'mainline/develop' into MC-3910-Align-animations
2 parents b45dd97 + 7cf64f0 commit a739e52

File tree

261 files changed

+11361
-11046
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

261 files changed

+11361
-11046
lines changed

app/code/Magento/PageBuilder/Block/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ private function getConfig(): array
5252
{
5353
$formNamespace = $this->getData('formNamespace');
5454
$attribute = $this->getData('attribute');
55+
$jsObjectName = $formNamespace . '_' . $attribute;
5556

5657
return [
5758
'formNamespace' => $formNamespace,
@@ -60,14 +61,16 @@ private function getConfig(): array
6061
[
6162
'form_namespace' => $formNamespace,
6263
'prefix' => $attribute,
64+
'js_object_name' => $jsObjectName,
6365
]
6466
),
65-
'jsObjectName' => $formNamespace . '_' . $attribute,
67+
'jsObjectName' => $jsObjectName,
6668
'childComponentUrl' => $this->getUrl(
6769
'pagebuilder/form/element_productconditions_child',
6870
[
6971
'form_namespace' => $formNamespace,
7072
'prefix' => $attribute,
73+
'js_object_name' => $jsObjectName,
7174
]
7275
),
7376
'attribute' => $attribute,

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function execute()
5454
$this->rule->loadPost(['conditions' => $this->serializer->unserialize($conditionsEncoded)]);
5555
$formName = $this->getRequest()->getParam('form_namespace');
5656
// Combine class recursively sets jsFormObject so we don't need to
57-
$conditions->setJsFormObject($formName);
57+
$conditions->setJsFormObject($this->getRequest()->getParam('js_object_name'));
5858
// The Combine class doesn't need the data attribute on children but we do.
5959
$this->configureConditionsFormName($conditions, $formName);
6060
$result = $conditions->asHtmlRecursive();

app/code/Magento/PageBuilder/Controller/Adminhtml/Form/Element/ProductConditions/Child.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public function execute()
3939
{
4040
$id = $this->getRequest()->getParam('id');
4141
$formName = $this->getRequest()->getParam('form_namespace');
42+
$jsObjectName = $this->getRequest()->getParam('js_object_name');
4243

4344
$typeData = explode('|', str_replace('-', '/', $this->getRequest()->getParam('type')));
4445
$className = $typeData[0];
@@ -55,7 +56,7 @@ public function execute()
5556

5657
$result = '';
5758
if ($model instanceof AbstractCondition) {
58-
$model->setJsFormObject($formName);
59+
$model->setJsFormObject($jsObjectName);
5960
$model->setFormName($formName);
6061
$result = $model->asHtmlRecursive();
6162
}

app/code/Magento/PageBuilder/Model/Config/ContentType/AdditionalData/Provider/Uploader/MaxFileSize.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

app/code/Magento/PageBuilder/Model/Stage/Renderer/CmsStaticBlock.php

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,29 @@ class CmsStaticBlock implements \Magento\PageBuilder\Model\Stage\RendererInterfa
3232
*/
3333
private $loggerInterface;
3434

35+
/**
36+
* @var \Magento\PageBuilder\Model\Stage\ScriptFilter
37+
*/
38+
private $scriptFilter;
39+
3540
/**
3641
* CmsStaticBlock constructor.
3742
*
3843
* @param \Magento\Cms\Model\ResourceModel\Block\CollectionFactory $blockCollectionFactory
3944
* @param WidgetDirective $widgetDirectiveRenderer
4045
* @param LoggerInterface $loggerInterface
46+
* @param \Magento\PageBuilder\Model\Stage\ScriptFilter $scriptFilter
4147
*/
4248
public function __construct(
4349
\Magento\Cms\Model\ResourceModel\Block\CollectionFactory $blockCollectionFactory,
4450
WidgetDirective $widgetDirectiveRenderer,
45-
LoggerInterface $loggerInterface
51+
LoggerInterface $loggerInterface,
52+
\Magento\PageBuilder\Model\Stage\ScriptFilter $scriptFilter
4653
) {
4754
$this->blockCollectionFactory = $blockCollectionFactory;
4855
$this->widgetDirectiveRenderer = $widgetDirectiveRenderer;
4956
$this->loggerInterface = $loggerInterface;
57+
$this->scriptFilter = $scriptFilter;
5058
}
5159

5260
/**
@@ -88,34 +96,11 @@ public function render(array $params): array
8896

8997
if ($block->isActive()) {
9098
$directiveResult = $this->widgetDirectiveRenderer->render($params);
91-
$result['content'] = $this->removeScriptTags($directiveResult['content']);
99+
$result['content'] = $this->scriptFilter->removeScriptTags($directiveResult['content']);
92100
} else {
93101
$result['error'] = __('Block disabled');
94102
}
95103

96104
return $result;
97105
}
98-
99-
/**
100-
* Remove script tag from html
101-
*
102-
* @param string $content
103-
* @return string
104-
*/
105-
private function removeScriptTags(string $content): string
106-
{
107-
$dom = new \DOMDocument();
108-
try {
109-
//this code is required because of https://bugs.php.net/bug.php?id=60021
110-
$previous = libxml_use_internal_errors(true);
111-
$dom->loadHTML($content);
112-
} catch (\Exception $e) {
113-
$this->loggerInterface->critical($e->getMessage());
114-
}
115-
libxml_use_internal_errors($previous);
116-
foreach (iterator_to_array($dom->getElementsByTagName('script')) as $item) {
117-
$item->parentNode->removeChild($item);
118-
}
119-
return $dom->saveHTML();
120-
}
121106
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\PageBuilder\Model\Stage;
10+
11+
use Psr\Log\LoggerInterface;
12+
13+
/**
14+
* Filters script tags from stage output
15+
*
16+
* @api
17+
*/
18+
class ScriptFilter
19+
{
20+
/**
21+
* @var LoggerInterface
22+
*/
23+
private $loggerInterface;
24+
25+
/**
26+
* ScriptFilter constructor.
27+
* @param LoggerInterface $loggerInterface
28+
*/
29+
public function __construct(
30+
LoggerInterface $loggerInterface
31+
) {
32+
$this->loggerInterface = $loggerInterface;
33+
}
34+
35+
/**
36+
* Remove script tag from html
37+
*
38+
* @param string $content
39+
* @return string
40+
*/
41+
public function removeScriptTags(string $content): string
42+
{
43+
$dom = new \DOMDocument();
44+
try {
45+
//this code is required because of https://bugs.php.net/bug.php?id=60021
46+
$previous = libxml_use_internal_errors(true);
47+
$dom->loadHTML($content, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD);
48+
} catch (\Exception $e) {
49+
$this->loggerInterface->critical($e->getMessage());
50+
}
51+
libxml_use_internal_errors($previous);
52+
foreach (iterator_to_array($dom->getElementsByTagName('script')) as $item) {
53+
$item->parentNode->removeChild($item);
54+
}
55+
return $dom->saveHTML();
56+
}
57+
}

app/code/Magento/PageBuilder/Model/Template/Filter.php

Lines changed: 0 additions & 136 deletions
This file was deleted.

app/code/Magento/PageBuilder/Plugin/Cms/Block/Block.php

Lines changed: 0 additions & 41 deletions
This file was deleted.

0 commit comments

Comments
 (0)