Skip to content

Commit 7cb4a6d

Browse files
ENGCOM-5761: #2228; Encode xml entities in tag attributes #24336
- Merge Pull Request #24336 from sergey-solo/magento2:m2-github-issue/2228 - Merged commits: 1. de8028e 2. 781e7bb 3. ada83e4 4. 5eaef76
2 parents db43c11 + 5eaef76 commit 7cb4a6d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/internal/Magento/Framework/Simplexml/Element.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ class Element extends \SimpleXMLElement
3030
* @param \Magento\Framework\Simplexml\Element $element
3131
* @return void
3232
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
33+
* phpcs:disable Magento2.CodeAnalysis.EmptyBlock
3334
*/
3435
public function setParent($element)
3536
{
36-
//$this->_parent = $element;
3737
}
38+
// phpcs:enable
3839

3940
/**
4041
* Returns parent node for the element
@@ -179,7 +180,8 @@ public function asArray()
179180
}
180181

181182
/**
182-
* asArray() analog, but without attributes
183+
* The asArray() analog, but without attributes
184+
*
183185
* @return array|string
184186
*/
185187
public function asCanonicalArray()
@@ -245,7 +247,7 @@ public function asNiceXml($filename = '', $level = 0)
245247
$attributes = $this->attributes();
246248
if ($attributes) {
247249
foreach ($attributes as $key => $value) {
248-
$out .= ' ' . $key . '="' . str_replace('"', '\"', (string)$value) . '"';
250+
$out .= ' ' . $key . '="' . str_replace('"', '\"', $this->xmlentities($value)) . '"';
249251
}
250252
}
251253

@@ -471,6 +473,7 @@ public function setNode($path, $value, $overwrite = true)
471473
* Unset self from the XML-node tree
472474
*
473475
* Note: trying to refer this object as a variable after "unsetting" like this will result in E_WARNING
476+
*
474477
* @return void
475478
*/
476479
public function unsetSelf()

0 commit comments

Comments
 (0)