diff -u b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php --- b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php +++ b/core/modules/views/src/Plugin/EntityReferenceSelection/ViewsSelection.php @@ -155,7 +155,7 @@ public function getReferenceableEntities($match = NULL, $match_operator = 'CONTAINS', $limit = 0) { $entities = []; if ($display_execution_results = $this->getDisplayExecutionResults($match, $match_operator, $limit)) { - $entities = $this->stripAnchorTagsFromResults($display_execution_results); + $entities = $this->stripAdminAndAnchorTagsFromResults($display_execution_results); } return $entities; } @@ -177,7 +177,7 @@ * @return array * The results. */ - public function getDisplayExecutionResults($match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) { + protected function getDisplayExecutionResults($match = NULL, $match_operator = 'CONTAINS', $limit = 0, $ids = NULL) { $display_name = $this->getConfiguration()['view']['display_name']; $arguments = $this->getConfiguration()['view']['arguments']; $results = []; @@ -188,7 +188,7 @@ } /** - * Strips anchor tags from a result list. + * Strips all admin and anchor tags from a result list. * * These results are usually displayed in an autocomplete field, which is * surrounded by anchor tags. Most tags are allowed inside anchor tags, except @@ -199,7 +199,7 @@ * @return array * The provided result list with anchor tags removed. */ - public function stripAnchorTagsFromResults($results) { + protected function stripAdminAndAnchorTagsFromResults($results) { $allowed_tags = Xss::getAdminTagList(); if (($key = array_search('a', $allowed_tags)) !== FALSE) { unset($allowed_tags[$key]); @@ -208,7 +208,10 @@ $stripped_results = []; foreach ($results as $id => $row) { $entity = $row['#row']->_entity; - $stripped_results[$entity->bundle()][$id] = Xss::filter($this->renderer->renderPlain($row), $allowed_tags); + $stripped_results[$entity->bundle()][$id] = [ + '#markup' => $this->renderer->renderPlain($row), + '#allowed_tags' => $allowed_tags, + ]; } return $stripped_results;