# Post with CDATA block produces invalid RSS feed?

**URL:** https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362
**Category:** Support
**Created:** [25. November 2016 um 12:32 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362 "2016-11-25T12:32:23Z")
**Posts on this page:** 19
**Page:** 1

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [25. November 2016 um 12:32 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/1 "2016-11-25T12:32:23Z")

</div>

I’m using Zapier to automatically post new topics on a Facebook page and I noticed that for last few days, the feeds (i.e. `/latest.rss`) aren’t posted anymore. The error that Zapier throws me is this:

```plaintext
The last error message was "mismatched tag: line 546, column 2".

```

What’s on line 546? This:

```plaintext
542| <script type="text/javascript">
543| <!--//--><![CDATA[//><!--
544| !function(a,b){"use strict";function c(){if(!e){e=!0;var a,c,d,f,g=-1!==navigator.appVersion.indexOf("MSIE 10"),h=!!navigator.userAgent.match(/Trident.*rv:11\./),i=b.querySelectorAll("iframe.wp-embedded-content");for(c=0;c<i.length;c++)if(d=i[c],!d.getAttribute("data-secret")){if(f=Math.random().toString(36).substr(2,10),d.src+="#?secret="+f,d.setAttribute("data-secret",f),g||h)a=d.cloneNode(!0),a.removeAttribute("security"),d.parentNode.replaceChild(a,d)}else;}}var d=!1,e=!1;if(b.querySelector)if(a.addEventListener)d=!0;if(a.wp=a.wp||{},!a.wp.receiveEmbedMessage)if(a.wp.receiveEmbedMessage=function(c){var d=c.data;if(d.secret||d.message||d.value)if(!/[^a-zA-Z0-9]/.test(d.secret)){var e,f,g,h,i,j=b.querySelectorAll('iframe[data-secret="'+d.secret+'"]'),k=b.querySelectorAll('blockquote[data-secret="'+d.secret+'"]');for(e=0;e<k.length;e++)k[e].style.display="none";for(e=0;e<j.length;e++)if(f=j[e],c.source===f.contentWindow){if(f.removeAttribute("style"),"height"===d.message){if(g=parseInt(d.value,10),g>1e3)g=1e3;else if(200>~~g)g=200;f.height=g}if("link"===d.message)if(h=b.createElement("a"),i=b.createElement("a"),h.href=f.getAttribute("src"),i.href=d.value,i.host===h.host)if(b.activeElement===f)a.top.location.href=d.value}else;}},d)a.addEventListener("message",a.wp.receiveEmbedMessage,!1),b.addEventListener("DOMContentLoaded",c,!1),a.addEventListener("load",c,!1)}(window,document);
545| //--><!]]>
546| </script><iframe sandbox="allow-scripts" security="restricted" src="https://blog.jetbrains.com/dotnet/2016/11/21/jetbrains-rider-public-preview/embed/" width="600" height="338" title="Embedded WordPress Post" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="wp-embedded-content"></iframe>

```

So I assume things are not playing as nice as they should.

Can we get a stripped down version of the RSS feed?

Thanks!

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [25. November 2016 um 18:30 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/2 "2016-11-25T18:30:12Z")

</div>

Hmm, can you check into the RSS feed issue on meta @techapj and see if it repros? maybe use a feed validator on a few different pages to make sure everything is OK on latest.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [26. November 2016 um 07:36 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/3 "2016-11-26T07:36:45Z")

</div>

I checked RSS feed for meta’s latest page and different category pages and they all are valid. (validated via [http://www.feedvalidator.org/](http://www.feedvalidator.org/))

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [26. November 2016 um 07:37 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/4 "2016-11-26T07:37:35Z")

</div>

Sounds like this is specific to some post on your site then, @iamntz

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [26. November 2016 um 12:04 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/5 "2016-11-26T12:04:56Z")

</div>

Any ideas on how i could debug this?

[http://www.feedvalidator.org/check.cgi?url=https%3A%2F%2Fdevforum.ro%2Flatest.rss](http://www.feedvalidator.org/check.cgi?url=https%3A%2F%2Fdevforum.ro%2Flatest.rss)

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [26. November 2016 um 22:30 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/6 "2016-11-26T22:30:26Z")

</div>

> [@codinghorror](#):
>
> Sounds like this is specific to some post

Yes. it is because the post has `<![CDATA[…]]>` in it.  
[Use CDATA in RSS Feed to add HTML and links | Amit Tech Lab - PHP, AJAX, CakePHP,WordPress, Symfony, Drupal, codeIgnitier](https://amittechlab.wordpress.com/2011/03/02/use-cdata-in-rss-feed-to-add-html-and-links/)

This results in something like

```plaintext
<description><![CDATA[… <![CDATA[ …]]> … ]]></description> 

```

The validator / parser doesn’t do nested CDATA well.

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [27. November 2016 um 07:19 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/7 "2016-11-27T07:19:04Z")

</div>

Alright, but what can _I_ do about this? There is anything in the admin area that I didn’t saw? It’s a bug?

Thanks!

---

<div class="post-metadata">

### Author: ![mpalmer](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mpalmer/32/45740_2.png) [@mpalmer](https://meta.discourse.org/u/mpalmer)
#### Post date: [27. November 2016 um 07:24 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/8 "2016-11-27T07:24:37Z")

</div>

> [@Mittineague](#):
>
> The validator / parser doesn’t do nested CDATA well.

Is nested CDATA valid? Perhaps it’s a validator bug.

> [@iamntz](#):
>
> Alright, but what can I do about this?

I can think of a few things:

1. Don’t use nested CDATA.

2. Determine whether nested CDATA is valid, and if it is, report it as a problem to the validator.

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [27. November 2016 um 07:36 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/9 "2016-11-27T07:36:31Z")

</div>

> [@iamntz](#):
>
> It’s a bug?

I wouldn’t call it a bug, but more an edge case.

> [@mpalmer](#):
>
> Is nested CDATA valid?

No

> **[2.7 CDATA Sections - Extensible Markup Language (XML) 1.0 (Fifth Edition)](https://www.w3.org/TR/REC-xml/#sec-cdata-sect)**
>
> \[Definition: CDATA sections may occur anywhere character data may occur; they are used to escape blocks of text containing characters which would otherwise be recognized as markup. CDATA sections begin with the string " \<!\[CDATA\[ " and end with the...

> Within a CDATA section, only the CDEnd string is recognized as markup, so that left angle brackets and ampersands may occur in their literal form; they need not (and cannot) be escaped using “`&lt;`” and “`&amp;`”. CDATA sections cannot nest.

> [@iamntz](#):
>
> what can I do about this?

The problem is, after the first `<![CDATA[` everything up to the `]]>` is considered to be “character data” and not XML tags. Once a `]]>` is encountered, it goes back to needing to be well-formed valid XML.

My first thought was to change the \< and / or ] to an entity. But after seeing the “and cannot” I guess that won’t work.

Maybe “breaking” the inner CDEnd by inserting zwsp characters would work?

> **[ZERO WIDTH SPACE (ZWSP) (U+200B)](https://www.fileformat.info/info/unicode/char/200B/index.htm)**
>
> Get the complete details on Unicode character U+200B on FileFormat.Info

EDIT

The RSS for this topic is valid and uses entities (`&lt; and &gt;`), so it looks like my first thought should work.

> **[Feed Validator Results:...](https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fmeta.discourse.org%2Ft%2Fpost-with-cdata-block-produces-invalid-rss-feed%2F53362.rss)**

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [27. November 2016 um 08:29 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/10 "2016-11-27T08:29:33Z")

</div>

Let’s try to embed the faulty url 🙂

> **[JetBrains Rider Early Access Program is now public | The .NET Tools Blog](https://blog.jetbrains.com/dotnet/2016/11/21/jetbrains-rider-public-preview/)**
>
> Back in January, we announced Project Rider. In March, we started the private Early Access Program. Today, we're very excited to announce that the Rider EAP is now open to everyone!We've had s

PS: not valid anymore 😊

---

<div class="post-metadata">

### Author: ![Mittineague](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mittineague/32/114259_2.png) [@Mittineague](https://meta.discourse.org/u/Mittineague)
#### Post date: [27. November 2016 um 09:50 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/11 "2016-11-27T09:50:27Z")

</div>

> [@iamntz](#):
>
> PS: not valid anymore

Well, yes.

It has already been established that it can be broken.

I’m more interested in your ideas about how to fix things so it won’t break.

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [27. November 2016 um 10:17 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/12 "2016-11-27T10:17:44Z")

</div>

I can see few approaches:

1. Allow only a handful of html tags on feeds (i.e. formatting tags, links, images)

- Block potential unsafe tags in feeds (iframe, object),
- Show only an excerpt (i.e. only a part of the topic, fully stripped of tags)

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [27. November 2016 um 16:36 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/13 "2016-11-27T16:36:18Z")

</div>

Are we sure this embed is correct @techapj / @zogstrip? It looks like a variable height embed to me which we shouldn’t even allow? The height of it is definitely incorrect onscreen in MS Edge.

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [27. November 2016 um 17:16 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/14 "2016-11-27T17:16:27Z")

</div>

Ah, yes, the height is another thing that is not like it should. Once, i had link which had a ~1000px height empty iframe, but since i wasn’t able to replicate, i ignore it.

So probably that’s related somehow.

---

<div class="post-metadata">

### Author: ![techAPJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/techapj/32/342990_2.png) [@techAPJ](https://meta.discourse.org/u/techAPJ)
#### Post date: [27. November 2016 um 17:20 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/15 "2016-11-27T17:20:25Z")

</div>

I remember fixing this issue via:

[https://github.com/discourse/onebox/commit/1b8bef8f96a4353cdfa6bc67da87d6750d5d31bf](https://github.com/discourse/onebox/commit/1b8bef8f96a4353cdfa6bc67da87d6750d5d31bf)

It was previously reported here:

> [@Onebox for WordPress 4.4 sites](https://meta.discourse.org/t/onebox-for-wordpress-4-4-sites/36765/8):
>
> Hmm. Yeah idk why the height is wrong. The image size is actually ok. When I try to embed the post in WordPress it looks fine. Either way, the blockquoted link above the embed should be hidden, right? blockquote.wp-embedded-content { display: none; } Height appears to be 338 for anything (notice the whitespace below this embed): It resizes inside of WordPress posts though (visit that link and watch the page load). So maybe there’s something going on in Discourse preventing it from res…

This is a recent regression.

cc @zogstrip

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [27. November 2016 um 18:44 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/16 "2016-11-27T18:44:10Z")

</div>

I’ll fix it. I did try it on a handful of Wordpress and they worked without it… Guess I was lucky. I’ll add it back ✏

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [28. November 2016 um 14:16 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/17 "2016-11-28T14:16:29Z")

</div>

Will be fixed soon 🍓

[https://github.com/discourse/onebox/commit/a4708d78382a206f5ff9d39cf5cb76b812d7fbb0](https://github.com/discourse/onebox/commit/a4708d78382a206f5ff9d39cf5cb76b812d7fbb0)

---

<div class="post-metadata">

### Author: ![iamntz](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/iamntz/32/114670_2.png) [@iamntz](https://meta.discourse.org/u/iamntz)
#### Post date: [28. November 2016 um 20:14 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/18 "2016-11-28T20:14:43Z")

</div>

Yup, this works fine now. Thanks!

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [28. November 2016 um 20:15 UTC](https://meta.discourse.org/t/post-with-cdata-block-produces-invalid-rss-feed/53362/19 "2016-11-28T20:15:05Z")

</div>


