Commit 146f084e authored by catch's avatar catch

Issue #2550467 and #2120113 by alexpott, manningpete, akalata, nlisgo, nod_,...

Issue #2550467 and #2120113 by alexpott, manningpete, akalata, nlisgo, nod_, harjotsingh: Remove #value_prefix and #value_suffix from HtmlTag
parent c89df1ce
......@@ -48,9 +48,6 @@ public function getInfo() {
/**
* Pre-render callback: Renders a generic HTML tag with attributes into #markup.
*
* Note: It is the caller's responsibility to sanitize #value_prefix and
* #value_suffix. They are not filtered by this function.
*
* @param array $element
* An associative array containing:
* - #tag: The tag name to output. Typical tags added to the HTML HEAD:
......@@ -62,12 +59,6 @@ public function getInfo() {
* tag. The attributes are escaped, see \Drupal\Core\Template\Attribute.
* - #value: (optional) A string containing tag content, such as inline
* CSS. The value of #value will be XSS admin filtered if it is not safe.
* - #value_prefix: (optional) A string to prepend to #value, e.g. a CDATA
* wrapper prefix. The value of #value_prefix cannot be filtered and is
* assumed to be safe.
* - #value_suffix: (optional) A string to append to #value, e.g. a CDATA
* wrapper suffix. The value of #value_suffix cannot be filtered and is
* assumed to be safe.
* - #noscript: (optional) If TRUE, the markup (including any prefix or
* suffix) will be wrapped in a <noscript> element. (Note that passing
* any non-empty value here will add the <noscript> tag.)
......@@ -88,13 +79,7 @@ public static function preRenderHtmlTag($element) {
// Construct all other elements.
else {
$markup .= '>';
if (isset($element['#value_prefix'])) {
$markup .= $element['#value_prefix'];
}
$markup .= SafeMarkup::isSafe($element['#value']) ? $element['#value'] : Xss::filterAdmin($element['#value']);
if (isset($element['#value_suffix'])) {
$markup .= $element['#value_suffix'];
}
$markup .= '</' . $escaped_tag . ">\n";
}
if (!empty($element['#noscript'])) {
......
......@@ -91,8 +91,6 @@ function testHtmlTag() {
'#type' => 'html_tag',
'#tag' => 'meta',
'#value' => 'ignored',
'#value_prefix' => 'ignored',
'#value_suffix' => 'ignored',
'#attributes' => array(
'name' => 'description',
'content' => 'Drupal test',
......@@ -104,12 +102,10 @@ function testHtmlTag() {
'#type' => 'html_tag',
'#tag' => 'section',
'#value' => 'value',
'#value_prefix' => 'value_prefix|',
'#value_suffix' => '|value_suffix',
'#attributes' => array(
'class' => array('unicorns'),
),
), '<section class="unicorns">value_prefix|value|value_suffix</section>' . "\n", "#type 'html_tag', non-void element renders properly");
), '<section class="unicorns">value</section>' . "\n", "#type 'html_tag', non-void element renders properly");
// Test empty void element tag.
$this->assertElements(array(
......
......@@ -121,7 +121,7 @@ function providerTestRender() {
'#browsers' => $browsers,
);
};
$create_style_element = function($value, $media, $browsers = array(), $wrap_in_cdata = FALSE) {
$create_style_element = function($value, $media, $browsers = array()) {
$style_element = array(
'#type' => 'html_tag',
'#tag' => 'style',
......@@ -131,10 +131,6 @@ function providerTestRender() {
),
'#browsers' => $browsers,
);
if ($wrap_in_cdata) {
$style_element['#value_prefix'] = "\n/* <![CDATA[ */\n";
$style_element['#value_suffix'] = "\n/* ]]> */\n";
}
return $style_element;
};
......
......@@ -46,12 +46,10 @@ public function providerPreRenderHtmlTag() {
// Value prefix/suffix.
$element = array(
'#value_prefix' => 'value_prefix|',
'#value_suffix' => '|value_suffix',
'#value' => 'value',
'#tag' => 'p',
);
$tags[] = array($element, '<p>value_prefix|value|value_suffix</p>' . "\n");
$tags[] = array($element, '<p>value</p>' . "\n");
// Normal element without a value should not result in a void element.
$element = array(
......@@ -99,15 +97,6 @@ public function providerPreRenderHtmlTag() {
);
$tags[] = array($element, "<p>value</p>\n");
// Ensure that #value_prefix and #value_suffix are not filtered.
$element = array(
'#tag' => 'p',
'#value' => 'value',
'#value_prefix' => '<script>value</script>',
'#value_suffix' => '<script>value</script>',
);
$tags[] = array($element, "<p><script>value</script>value<script>value</script></p>\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