Commit ffa979ba authored by catch's avatar catch

Issue #2563069 by DuaelFr, ecarty, idebr: Unclosed conditional comments in...

Issue #2563069 by DuaelFr, ecarty, idebr: Unclosed conditional comments in html tag result in broken html head
parent 62346123
......@@ -87,19 +87,19 @@ public static function preRenderHtmlTag($element) {
$escaped_tag = HtmlUtility::escape($element['#tag']);
$open_tag = '<' . $escaped_tag . $attributes;
$close_tag = '</' . $escaped_tag . ">\n";
$prefix = isset($element['#prefix']) ? $element['#prefix'] . $open_tag : $open_tag;
$suffix = isset($element['#suffix']) ? $close_tag . $element['#suffix'] : $close_tag;
// Construct a void element.
if (in_array($element['#tag'], self::$voidElements)) {
$prefix .= " />\n";
$suffix = '';
$open_tag .= ' />';
$close_tag = "\n";
}
// Construct all other elements.
else {
$prefix .= '>';
$open_tag .= '>';
$markup = $element['#value'] instanceof MarkupInterface ? $element['#value'] : Xss::filterAdmin($element['#value']);
$element['#markup'] = Markup::create($markup);
}
$prefix = isset($element['#prefix']) ? $element['#prefix'] . $open_tag : $open_tag;
$suffix = isset($element['#suffix']) ? $close_tag . $element['#suffix'] : $close_tag;
if (!empty($element['#noscript'])) {
$prefix = '<noscript>' . $prefix;
$suffix .= '</noscript>';
......
......@@ -202,6 +202,22 @@ public function providerPreRenderHtmlTag() {
];
$tags['linearGradient'] = [$element, '<linearGradient><stop offset="5%" stop-color="#F60" />' . "\n" . '<stop offset="95%" stop-color="#FF6" />' . "\n" . '</linearGradient>' . "\n"];
// Simple link.
$element = [
'#tag' => 'link',
];
$tags['link'] = [HtmlTag::preRenderConditionalComments($element), '<link />' . "\n"];
// Conditional link.
$element = [
'#tag' => 'link',
'#browsers' => [
'IE' => TRUE,
'!IE' => FALSE,
],
];
$tags['conditional-link'] = [HtmlTag::preRenderConditionalComments($element), "\n" . '<!--[if IE]>' . "\n" . '<link />' . "\n" . '<![endif]-->' . "\n"];
return $tags;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment