Score:4

Allow SVG in Views Rewrite Results

cn flag

I am rewriting the results of a field in a View and depending on the value of a field, I want to display an SVG icon. I can use TWIG to do the conditional logic and that works great, but it won't let me use the SVG tag. There is help text below that says:

You may include Twig or the following allowed HTML tags: <a> <abbr> <acronym> <address> <article> <aside> <b> <bdi> <bdo> <big> <blockquote> <br> <caption> <cite> <code> <col> <colgroup> <command> <dd> <del> <details> <dfn> <div> <dl> <dt> <em> <figcaption> <figure> <footer> <h1> <h2> <h3> <h4> <h5> <h6> <header> <hgroup> <hr> <i> <img> <ins> <kbd> <li> <mark> <menu> <meter> <nav> <ol> <output> <p> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <section> <small> <span> <strong> <sub> <summary> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <time> <tr> <tt> <u> <ul> <var> <wbr>

So as you can see, SVG is not there. Is there a way to make it allowable?

Score:3
ua flag

You can get around it by doing the overriding via template file rather than views config.

If you would like to allow it on views config and as long as you feel comfortable that non of your admins will do any evil XSS using svg to seek higher admin power and take over the world site, you could patch https://github.com/drupal/core/blob/9.3.x/lib/Drupal/Component/Utility/Xss.php#L21.

cn flag
This did indeed work. THANKS
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.