Problem/Motivation
The entity_reference_label
field formatter always assigns the output of EntityInterface::label()
to a #plain_text
render element, even though it can return an instance of TranslatableMarkup
which can contain safe markup.
Steps to reproduce
Override the label
method in an entity class and make it return an instance of MarkupInterface
. Render an entity of that class with the entity_reference_label
field formatter. The markup will be escaped.
Proposed resolution
Don't escape markup if it's safe.