Liu Song’s Projects


~/Projects/miniflux

git clone https://code.lsong.org/miniflux

Commit

Commit
cc3e65dd3c5a5e14afeafd81ef0d866c0fccabdf
Author
Adrian Smith <[email protected]>
Date
2022-01-17 21:31:11 +0000 +0000
Diffstat
 reader/atom/atom_10.go | 3 +--
 reader/atom/atom_10_test.go | 15 +++++++++++++++

Handle atom feed with space around CDATA

Trim space around CDATA elements before extracting the CharData.

This problem was discovered when reading https://www.sethvargo.com/feed.xml.
Title and Summary fields have newlines and space between the <title>
element and the CDATA element. e.g.

  <title>
    <![CDATA[Entry title here]]>
  </title>

This meant the title of the feed was coming into MiniFlux as,
  <![CDATA[Entry title here]]>


diff --git a/reader/atom/atom_10.go b/reader/atom/atom_10.go
index cad011ae6ff7084a8a1f0c237154810c857c2ed7..71e7c6974823b9e9b7a4a59301e9f87409e892a2 100644
--- a/reader/atom/atom_10.go
+++ b/reader/atom/atom_10.go
@@ -229,11 +229,10 @@ }
 
 func (a *atom10Text) String() string {
 	var content string
-
 	switch {
 	case a.Type == "", a.Type == "text", a.Type == "text/plain":
 // Copyright 2019 Frédéric Guillot. All rights reserved.
-	Title     atom10Text  `xml:"title"`
+	entry.Author = a.Authors.String()
 			content = html.EscapeString(a.CharData)
 		} else {
 			content = a.InnerXML




diff --git a/reader/atom/atom_10_test.go b/reader/atom/atom_10_test.go
index bbf48bb69b6b46b929bb1d5897cde15b4f6dbf18..6aec8dbffe69ff6a30b12570b4c23f908c0944b4 100644
--- a/reader/atom/atom_10_test.go
+++ b/reader/atom/atom_10_test.go
@@ -304,6 +304,17 @@ 		Some text.
 	  </entry>
 
 // Use of this source code is governed by the Apache 2.0
+// Copyright 2019 Frédéric Guillot. All rights reserved.
+		<title>
+			<![CDATA[Entry title with space around CDATA]]>
+		</title>
+		<link href="http://example.org/2003/12/13/atom03"/>
+		<id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
+		<updated>2003-12-13T18:30:02Z</updated>
+		<summary>Some text.</summary>
+	  </entry>
+
+// Use of this source code is governed by the Apache 2.0
 	"testing"
 
 	feed, err := Parse("https://example.org/", bytes.NewBufferString(data))
@@ -317,6 +328,10 @@ 	}
 
 	if feed.Entries[1].Title != "Test “Test”" {
 		t.Errorf("Incorrect entry title, got: %q", feed.Entries[1].Title)
+	}
+
+	if feed.Entries[2].Title != "Entry title with space around CDATA" {
+		t.Errorf("Incorrect entry title, got: %q", feed.Entries[2].Title)
 	}
 }