Title: Unsafe HTML by Feed
Last modified: July 5, 2023

---

# Unsafe HTML by Feed

 *  Resolved [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/)
 * I have a feed that contains html in a CDATA section containing images ( i.e. 
   it contains img src tags). This feed is TRUSTED, and I want to import the html
   tags into posts. Some tags however, like images, are stripped away upon import.
   
   I tried some actions from the docs ( like using ‘feedzy_modify_feed_config’ to
   set    $feed->strip_attributes(false); , or like overwriting ‘feedzy_summary_input’
   to skip filtering for some feeds, but all this did not work. The filters/actions
   I tried were taken from the shortcode docs and probably are not exectuted when
   importing.
 * The only thing that worked, was setting
 * define( ‘FEEDZY_ALLOW_UNSAFE_HTML’, true );
   according to [https://docs.themeisle.com/article/1154-how-to-use-feed-to-post-feature-in-feedzy](https://docs.themeisle.com/article/1154-how-to-use-feed-to-post-feature-in-feedzy)
 * This does not feel good, since it allows HTML now in every feed. Is there any
   way to set this for specific feeds only, like in a filter that is executed when
   feed items are turned into posts?
 * Regards
 * Ulrich
    -  This topic was modified 2 years, 10 months ago by [ulicgn](https://wordpress.org/support/users/ulicgn/).
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Funsafe-html-by-feed%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 8 replies - 1 through 8 (of 8 total)

 *  Plugin Support [AndreeaR](https://wordpress.org/support/users/andreearadacina21/)
 * (@andreearadacina21)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16874874)
 * Hi [@ulicgn](https://wordpress.org/support/users/ulicgn/),
 * Thank you for using Feedzy!
 * We have a helpful document that explains how you can preserve HTML in your feed
   items’ content. You can find it here: [https://docs.themeisle.com/article/542-how-to-keep-html-in-feed-items-content](https://docs.themeisle.com/article/542-how-to-keep-html-in-feed-items-content).
 * Please feel free to reach out if you have any further questions or if there’s
   anything else we can assist you with.
 *  Thread Starter [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16875776)
 * [@andreearadacina21](https://wordpress.org/support/users/andreearadacina21/) 
   thank you for this pointer – I was not aware of this documentation. What I had
   tried was taken from [https://docs.themeisle.com/article/942-in-feedzy-how-do-i#remove-html-tags](https://docs.themeisle.com/article/942-in-feedzy-how-do-i#remove-html-tags),
   and it did not work for me ( since it was probably meant for the shortcode usage)
   Looks quite similar though, with minor differences.
 * So I will certainly try it and report back how it worked, however I can do that
   not before next Tuesday. Until then, I would leave this topic in unresolved state.
   Thanks and best regards,
 * Uli
 *  Thread Starter [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16883409)
 * [@andreearadacina21](https://wordpress.org/support/users/andreearadacina21/) 
   I disabled the FEEDZY_ALLOW_UNSAFE_HTML define and tried your code as suggested,
   with minor modifications. To identify the filter, I added “(unfiltered)” or “(
   filtered)” to the output:
 *     ```wp-block-code
       function kdefd_summary_input( $description, $content, $feedURL ) {
           //If you want to use the item content as the description. If not, then remove this line
           //If feed don't have content meta, $content is already equal to $description
           $description = $content;
   
          if (strpos($feedURL, "my-trusted-feed-domain.de") !== false) {
               $description = $description . " (unfiltered)";
               } else {
           //Remove the item HTML tags (as in the default hook) if not in the above list
               $description = trim( strip_tags( $description ) ) . " (filtered) ";
           }
   
           //Remove hellip (as in the default hook)
           //Keep in mind that it will be added later in the plugin render
           $description = trim( chop( $description, '[&hellip;]' ) );
   
           return $description;
       }
       ```
   
 * In the source feed, there is a CDATA description section containing some HTML
   tags:
 *     ```wp-block-code
       <item>
        <guid>https://www.example.com/5540093</guid>
        <link>https://www.example.com/5540093</link>
        <pubDate>Wed, 21 Jun 2023 14:16:46 +0200</pubDate>
        <title><![CDATA[ My Title as CDATA ]]></title>
        <description><![CDATA[Köln (ots) - 
       SOME LONG TEXT ....
   
       <div class="pp-image" data-src="https://example.com/story_big/20bdf4d9-c4f2-4bf3-be90-3a766f048dd8/Foto1.jpg" data-caption="Foto 1">
       <span class="pp-caption">Foto 1</span><br><img src="https://example.com/story_big/20bdf4d9-c4f2-4bf3-be90-3a766f048dd8/Foto1.jpg" alt="Foto 1"/></div>
   
       <div class="pp-image" data-src="https://example.com/story_big/f3e2b762-4387-4d87-877e-7ecb8246db2a/Foto2.jpg" data-caption="Foto 2">
       <span class="pp-caption">Foto 2</span><br><img src="https://example.com/story_big/f3e2b762-4387-4d87-877e-7ecb8246db2a/Foto2.jpg" alt="Foto 2"/></div>
   
       <div class="pp-source">Quelle:<a href="https://www.example.com/5540093">https://www.example.com/5540093</a></div>
   
        ]]></description></item>
       ```
   
 * In the Map-Content section, I configured the [#item_description] placeholder 
   for the import into posts. 
   The resulting post contains the “(unfiltered)” text,
   so the filter is indeed executed. However, the <img src… tags are missing, only
   the <a href…> tags are there. :
 *     ```wp-block-code
       Output in the Post:
       <div class="pp-image"><span class="pp-caption">Foto 1</span></div>
       <div class="pp-image"><span class="pp-caption">Foto 2</span></div>
       <div class="pp-source">Quelle:<a href="valid-URL" rel="noopener">....</a></div>
       (unfiltered)
       ```
   
 * So far, the only way to keep the <img src seems to be the FEEDZY_ALLOW_UNSAFE_HTML
   define …
    RegardsUlrich
    -  This reply was modified 2 years, 10 months ago by [ulicgn](https://wordpress.org/support/users/ulicgn/).
    -  This reply was modified 2 years, 10 months ago by [ulicgn](https://wordpress.org/support/users/ulicgn/).
 *  [luciamarinescu](https://wordpress.org/support/users/luciamarinescu/)
 * (@luciamarinescu)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16895541)
 * Hi [@ulicgn](https://wordpress.org/support/users/ulicgn/)!
 * Could you please provide us the feed URL so we can test it on our end?
 * Thank you!
 *  Thread Starter [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16896164)
 * Thanks for following up!! While the feed is technically “public” ( i.e. not protected),
   the URL is not to be published in a forum. How could I send you the feed URL (
   or a sample file – whatever you prefer) safely? Regards, Ulrich
 *  Thread Starter [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 10 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16899923)
 * [@luciamarinescu](https://wordpress.org/support/users/luciamarinescu/) I made
   a Demo feeed that is structurally identical to the original one and whose URL
   can be published. See here:
 * [https://cdn01.koeln.de/uploads/files/demofeed.xml](https://cdn01.koeln.de/uploads/files/demofeed.xml)(
   like the original feed, this feed validates when checked with the w3c online 
   validator)
 * There is one item with img src in CDATA. With the code mentioned by [@andreearadacina21](https://wordpress.org/support/users/andreearadacina21/),
   the img src tags are wiped out, with FEEDZY_ALLOW_UNSAFE_HTML they are kept.
    -  This reply was modified 2 years, 10 months ago by [ulicgn](https://wordpress.org/support/users/ulicgn/).
 *  [luciamarinescu](https://wordpress.org/support/users/luciamarinescu/)
 * (@luciamarinescu)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16939654)
 * Hi [@ulicgn](https://wordpress.org/support/users/ulicgn/)!
 * Indeed, it should possible to display those tags with this line of code.
 * define( ‘FEEDZY_ALLOW_UNSAFE_HTML’, true );
 * Unfortunately, our support team can’t help with customizations such as creating
   a filter to allow unsafe html only for a certain feed as it’s beyond the level
   of assistance we provide. The good news is that other users from the community
   can see the thread and might want to help in this regard.
 * Thanks for understanding and have a nice day ahead!
 *  Thread Starter [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * (@ulicgn)
 * [2 years, 9 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16941890)
 * What a pity, I had the impression that we were more than half way there. Obviously
   $description gets processed and tag-stripped once more later on, so the effects
   of this filter are overridden.
 * Even though I don’t think that someone will show up and solve this, I will leave
   this topic open for another couple of days before closing it.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Unsafe HTML by Feed’ is closed to new replies.

 * ![](https://ps.w.org/feedzy-rss-feeds/assets/icon-256x256.gif?rev=3418285)
 * [RSS Aggregator by Feedzy – Feed to Post, Autoblogging, News & YouTube Video Feeds Aggregator](https://wordpress.org/plugins/feedzy-rss-feeds/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/feedzy-rss-feeds/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/feedzy-rss-feeds/)
 * [Active Topics](https://wordpress.org/support/plugin/feedzy-rss-feeds/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/feedzy-rss-feeds/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/feedzy-rss-feeds/reviews/)

 * 8 replies
 * 3 participants
 * Last reply from: [ulicgn](https://wordpress.org/support/users/ulicgn/)
 * Last activity: [2 years, 9 months ago](https://wordpress.org/support/topic/unsafe-html-by-feed/#post-16941890)
 * Status: resolved