title: When parsing Atom XML feeds, how should conflicting CDATA and entity escaped elements be handled?
body: <p>How should an Atom feed parser handle the following line of XML in a feed:</p>
  <pre><code>&lt;title type=&quot;html&quot;&gt;&lt;![CDATA[Johnson &amp;amp; Johnson]]&gt;&lt;/title&gt;
  </code></pre>
  <p>For the sake of the discussion, lets assume that the originally intended text was in fact <code>Johnson &amp; Johnson</code>.  I came across this <a href="https://core.trac.wordpress.org/ticket/9992" rel="nofollow noreferrer">online discussion</a> about this issue and there seemed to be 2 different opinions:</p>
  <p>1.
  <a href="https://core.trac.wordpress.org/ticket/9992#comment:16" rel="nofollow noreferrer"> Opinion #1 - claims that this content is double-encoded</a>.  The text &quot;Johnson &amp; Johnson&quot; text has been entity escaped and then encoded again by being wrapped in a CDATA section.  He states that a well behaved xml parser will return <code>Johnson &amp;amp; Johnson</code>, because this is how the <a href="http://www.w3.org/TR/REC-xml/#sec-cdata-sec" rel="nofollow noreferrer">XML spec</a> states CDATA encoded data should be handled.</p>
  <ol start="2">
  <li><a href="https://core.trac.wordpress.org/ticket/9992#comment:18" rel="nofollow noreferrer">Opinion #2 - claims that the Atom spec takes precedent</a>.  He states that the CDATA acts as a passthrough. <code>Johnson &amp;amp; Johnson</code> comes out as <code>Johnson &amp;amp; Johnson</code>. If this were just an XML document, it would end there. However, because it is Atom, we must then look at the <a href="https://www.rfc-editor.org/rfc/rfc4287#section-3.1.1.2" rel="nofollow noreferrer">Atom spec</a> to determine the proper behavior.  The atom spec states that any element with the <code>type=&quot;html&quot;</code> contains entity escaped html.  Therefore, we should be free to decode it.</li>
  </ol>
  <p>Which of these factually correct?   Should a proper Atom XML parser produce:
  <code>Johnson &amp; Johnson</code> or <code>Johnson &amp;amp; Johnson</code> given this particular situation?</p>