Improve handling of Atom text content with CDATA
This commit is contained in:
parent
c8c1f05328
commit
5877048749
2 changed files with 7 additions and 5 deletions
|
@ -231,10 +231,12 @@ func (a *atom10Text) String() string {
|
|||
var content string
|
||||
|
||||
switch {
|
||||
case strings.HasPrefix(a.InnerXML, `<![CDATA[`):
|
||||
content = a.CharData
|
||||
case a.Type == "", a.Type == "text", a.Type == "text/plain":
|
||||
content = a.InnerXML
|
||||
if strings.HasPrefix(a.InnerXML, `<![CDATA[`) {
|
||||
content = html.EscapeString(a.CharData)
|
||||
} else {
|
||||
content = a.InnerXML
|
||||
}
|
||||
case a.Type == "xhtml":
|
||||
if a.XHTMLRootElement.InnerXML != "" {
|
||||
content = a.XHTMLRootElement.InnerXML
|
||||
|
|
|
@ -531,7 +531,7 @@ func TestParseEntryWithTextSummary(t *testing.T) {
|
|||
<link href="http://example.org/d"/>
|
||||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
<summary type="text"><![CDATA[AT&T <S>]]></summary>
|
||||
<summary type="text"><![CDATA[AT&T <S>]]></summary>
|
||||
</entry>
|
||||
</feed>`
|
||||
|
||||
|
@ -583,7 +583,7 @@ func TestParseEntryWithTextContent(t *testing.T) {
|
|||
<link href="http://example.org/d"/>
|
||||
<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
|
||||
<updated>2003-12-13T18:30:02Z</updated>
|
||||
<content><![CDATA[AT&T <S>]]></content>
|
||||
<content><![CDATA[AT&T <S>]]></content>
|
||||
</entry>
|
||||
|
||||
</feed>`
|
||||
|
|
Loading…
Reference in a new issue