File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed
lib/internal/Magento/Framework/View/Helper/SecureHtmlRender Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change 13
13
*/
14
14
class HtmlRenderer
15
15
{
16
+
17
+ /**
18
+ * List of void elements which require a self-closing tag and don't allow content
19
+ *
20
+ * @var array
21
+ */
22
+ private const VOID_ELEMENTS = [
23
+ 'area ' ,
24
+ 'base ' ,
25
+ 'br ' ,
26
+ 'col ' ,
27
+ 'command ' ,
28
+ 'embed ' ,
29
+ 'hr ' ,
30
+ 'img ' ,
31
+ 'input ' ,
32
+ 'keygen ' ,
33
+ 'link ' ,
34
+ 'meta ' ,
35
+ 'param ' ,
36
+ 'source ' ,
37
+ 'track ' ,
38
+ 'wbr '
39
+ ];
40
+
16
41
/**
17
42
* @var Escaper
18
43
*/
@@ -49,10 +74,10 @@ public function renderTag(TagData $tagData): string
49
74
}
50
75
51
76
$ html = '< ' .$ tagData ->getTag () .$ attributesHtml ;
52
- if ($ content ) {
53
- $ html .= '> ' .$ content .'</ ' .$ tagData ->getTag () .'> ' ;
54
- } else {
77
+ if (in_array ($ tagData ->getTag (), self ::VOID_ELEMENTS )) {
55
78
$ html .= '/> ' ;
79
+ } else {
80
+ $ html .= '> ' .$ content .'</ ' .$ tagData ->getTag () .'> ' ;
56
81
}
57
82
58
83
return $ html ;
You can’t perform that action at this time.
0 commit comments