Adding allowed tags to custom text Views in Drupal8/9

Bad advice on how to quickly add the desired allowed tag to the custom text of the views.

In my example, it was necessary to add an icon in the svg format to the text. To do this, go to

core/lib/Drupal/Component/Utility/Xss.php

and in line 21 we see a list of allowed tags. As we know, the tag path is present in the svg image, so we add the tags svg and path . After that, we clear the cache and add the code of our svg icon to the text.

Why I called this advice harmful is because it is highly undesirable to make changes to the kernel files, if only because when you upgrade, with a 99.9% probability, your changes may be lost and you will have to do everything all over again. That is, this solution is only a temporary option, until you find a more correct approach to solving this problem.

As a possible, but not the fastest option - to make an additional style for displaying the necessary content, add the necessary fields in the content display settings, create a custom twig template for display in the view and in the view itself display an entity ready for display with our new display style. Yes, this option is not the fastest, but thanks to it, you can firstly make the view output cleaner from unnecessary code, and secondly, add any code and any markup that is generally processed by the engine to it.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.
The comment language code.