Skip to content

Commit 2eaee52

Browse files
author
ogorkun
committed
MC-34385: Filter fields allowing HTML
1 parent 1ef4801 commit 2eaee52

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

app/code/Magento/Cms/Model/PageRepository.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\EntityManager\HydratorInterface;
1818
use Magento\Framework\Exception\CouldNotDeleteException;
1919
use Magento\Framework\Exception\CouldNotSaveException;
20+
use Magento\Framework\Exception\LocalizedException;
2021
use Magento\Framework\Exception\NoSuchEntityException;
2122
use Magento\Framework\Reflection\DataObjectProcessor;
2223
use Magento\Store\Model\StoreManagerInterface;
@@ -162,24 +163,28 @@ private function validateLayoutUpdate(Data\PageInterface $page): void
162163
*/
163164
public function save(\Magento\Cms\Api\Data\PageInterface $page)
164165
{
165-
if ($page->getStoreId() === null) {
166-
$storeId = $this->storeManager->getStore()->getId();
167-
$page->setStoreId($storeId);
168-
}
169-
$pageId = $page->getId();
170-
if ($pageId && !($page instanceof Page && $page->getOrigData())) {
171-
$page = $this->hydrator->hydrate($this->getById($pageId), $this->hydrator->extract($page));
172-
}
173-
174166
try {
167+
$pageId = $page->getId();
168+
if ($pageId && !($page instanceof Page && $page->getOrigData())) {
169+
$page = $this->hydrator->hydrate($this->getById($pageId), $this->hydrator->extract($page));
170+
}
171+
if ($page->getStoreId() === null) {
172+
$storeId = $this->storeManager->getStore()->getId();
173+
$page->setStoreId($storeId);
174+
}
175175
$this->validateLayoutUpdate($page);
176176
$this->resource->save($page);
177177
$this->identityMap->add($page);
178-
} catch (\Exception $exception) {
178+
} catch (LocalizedException $exception) {
179179
throw new CouldNotSaveException(
180180
__('Could not save the page: %1', $exception->getMessage()),
181181
$exception
182182
);
183+
} catch (\Throwable $exception) {
184+
throw new CouldNotSaveException(
185+
__('Could not save the page: %1', __('Something went wrong while saving the page.')),
186+
$exception
187+
);
183188
}
184189
return $page;
185190
}

app/code/Magento/Cms/etc/di.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,8 @@
285285
<item name="hr" xsi:type="string">hr</item>
286286
<item name="figure" xsi:type="string">figure</item>
287287
<item name="button" xsi:type="string">button</item>
288+
<item name="i" xsi:type="string">i</item>
289+
<item name="u" xsi:type="string">u</item>
288290
</argument>
289291
<argument name="allowedAttributes" xsi:type="array">
290292
<item name="class" xsi:type="string">class</item>

0 commit comments

Comments
 (0)