diff --git a/core/modules/simpletest/src/AssertContentTrait.php b/core/modules/simpletest/src/AssertContentTrait.php index a425f4f..0dd3ca1 100644 --- a/core/modules/simpletest/src/AssertContentTrait.php +++ b/core/modules/simpletest/src/AssertContentTrait.php @@ -812,7 +812,7 @@ protected function assertThemeOutput($callback, array $variables = array(), $exp /** @var \Drupal\Core\Render\RendererInterface $renderer */ $renderer = \Drupal::service('renderer'); - $output = $renderer->executeInRenderContext(new RenderContext(), function() use ($callback, $variables) { + $output = (string) $renderer->executeInRenderContext(new RenderContext(), function() use ($callback, $variables) { return \Drupal::theme()->render($callback, $variables); }); $this->verbose( diff --git a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php index c83b9c4..a62a862 100644 --- a/core/modules/views/src/Plugin/views/field/FieldPluginBase.php +++ b/core/modules/views/src/Plugin/views/field/FieldPluginBase.php @@ -1214,6 +1214,7 @@ public function isValueEmpty($value, $empty_zero, $no_skip_empty = TRUE) { */ public function renderText($alter) { $value = $this->last_render; + $value_is_safe = SafeMarkup::isSafe($value); if (!empty($alter['alter_text']) && $alter['text'] !== '') { $tokens = $this->getRenderTokens($alter); @@ -1239,6 +1240,9 @@ public function renderText($alter) { if ($alter['phase'] == static::RENDER_TEXT_PHASE_EMPTY && $no_rewrite_for_empty) { // If we got here then $alter contains the value of "No results text" // and so there is nothing left to do. + if ($value_is_safe) { + $value = SafeString::create($value); + } return $value; } @@ -1275,6 +1279,11 @@ public function renderText($alter) { if (!empty($alter['nl2br'])) { $value = nl2br($value); } + + // Preserve whether or not the string is safe. + if ($value_is_safe) { + $value = SafeString::create($value . $suffix); + } $this->last_render_text = $value; if (!empty($alter['make_link']) && (!empty($alter['path']) || !empty($alter['url']))) { @@ -1284,7 +1293,13 @@ public function renderText($alter) { $value = $this->renderAsLink($alter, $value, $tokens); } - return $value . $suffix; + // Preserve whether or not the string is safe. + if ($value_is_safe) { + return SafeString::create($value . $suffix); + } + else { + return $value . $suffix; + } } /**