|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Copyright © Magento, Inc. All rights reserved. |
4 | | - * See COPYING.txt for license details. |
| 3 | + * Copyright 2011 Adobe |
| 4 | + * All Rights Reserved. |
5 | 5 | */ |
6 | 6 | namespace Magento\Framework\View\Model\Layout; |
7 | 7 |
|
@@ -564,6 +564,21 @@ protected function _loadXmlString($xmlString) |
564 | 564 | return simplexml_load_string($xmlString, \Magento\Framework\View\Layout\Element::class); |
565 | 565 | } |
566 | 566 |
|
| 567 | + /** |
| 568 | + * Return object representation of XML string, or false, if XML was invalid |
| 569 | + * |
| 570 | + * @param string $xmlString |
| 571 | + * @return \SimpleXMLElement|false |
| 572 | + */ |
| 573 | + protected function _safeLoadXmlString(string $xmlString): \SimpleXMLElement|false |
| 574 | + { |
| 575 | + return simplexml_load_string( |
| 576 | + $xmlString, |
| 577 | + \Magento\Framework\View\Layout\Element::class, |
| 578 | + LIBXML_NOWARNING | LIBXML_NOERROR |
| 579 | + ); |
| 580 | + } |
| 581 | + |
567 | 582 | /** |
568 | 583 | * Merge layout update by handle |
569 | 584 | * |
@@ -988,15 +1003,7 @@ public function getCacheId() |
988 | 1003 | private function extractHandlers(): void |
989 | 1004 | { |
990 | 1005 | foreach ($this->updates as $update) { |
991 | | - $updateXml = null; |
992 | | - |
993 | | - try { |
994 | | - $updateXml = is_string($update) ? $this->_loadXmlString($update) : false; |
995 | | - // phpcs:ignore Magento2.CodeAnalysis.EmptyBlock |
996 | | - } catch (\Exception $exception) { |
997 | | - // ignore invalid |
998 | | - } |
999 | | - |
| 1006 | + $updateXml = is_string($update) ? $this->_safeLoadXmlString($update) : false; |
1000 | 1007 | if ($updateXml && strtolower($updateXml->getName()) == 'update' && isset($updateXml['handle'])) { |
1001 | 1008 | $this->addHandle((string)$updateXml['handle']); |
1002 | 1009 | } |
|
0 commit comments