diff --git a/src/main/java/com/sun/syndication/io/impl/RSS092Parser.java b/src/main/java/com/sun/syndication/io/impl/RSS092Parser.java
index b90acaf..8a223d7 100644
--- a/src/main/java/com/sun/syndication/io/impl/RSS092Parser.java
+++ b/src/main/java/com/sun/syndication/io/impl/RSS092Parser.java
@@ -19,7 +19,9 @@ package com.sun.syndication.io.impl;
import java.util.ArrayList;
import java.util.List;
+import org.jdom2.Content;
import org.jdom2.Element;
+import org.jdom2.output.XMLOutputter;
import com.sun.syndication.feed.WireFeed;
import com.sun.syndication.feed.rss.Category;
@@ -166,8 +168,33 @@ public class RSS092Parser extends RSS091UserlandParser {
@Override
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
- final Description desc = super.parseItemDescription(rssRoot, eDesc);
- desc.setType("text/html");
+ final Description desc = new Description();
+ final StringBuilder sb = new StringBuilder();
+ final XMLOutputter xmlOut = new XMLOutputter();
+ for (final Content c : eDesc.getContent()) {
+ switch (c.getCType()) {
+ case Text:
+ case CDATA:
+ sb.append(c.getValue());
+ break;
+ case EntityRef:
+ System.out.println("entity: " + c.getValue());
+ sb.append(c.getValue());
+ break;
+ case Element:
+ sb.append(xmlOut.outputString((Element) c));
+ break;
+ default:
+ // ignore
+ break;
+ }
+ }
+ desc.setValue(sb.toString());
+ String att = eDesc.getAttributeValue("type");
+ if (att == null) {
+ att = "text/html";
+ }
+ desc.setType(att);
return desc;
}
diff --git a/src/main/java/com/sun/syndication/io/impl/RSS094Parser.java b/src/main/java/com/sun/syndication/io/impl/RSS094Parser.java
index 3a68c63..72aad41 100644
--- a/src/main/java/com/sun/syndication/io/impl/RSS094Parser.java
+++ b/src/main/java/com/sun/syndication/io/impl/RSS094Parser.java
@@ -98,16 +98,4 @@ public class RSS094Parser extends RSS093Parser {
return item;
}
- @Override
- protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
- final Description desc = super.parseItemDescription(rssRoot, eDesc);
- String att = eDesc.getAttributeValue("type");// getRSSNamespace()); DONT
- // KNOW WHY DOESN'T WORK
- if (att == null) {
- att = "text/html";
- }
- desc.setType(att);
- return desc;
- }
-
}
diff --git a/src/main/java/com/sun/syndication/io/impl/RSS20Parser.java b/src/main/java/com/sun/syndication/io/impl/RSS20Parser.java
index 9051c13..51fcf60 100644
--- a/src/main/java/com/sun/syndication/io/impl/RSS20Parser.java
+++ b/src/main/java/com/sun/syndication/io/impl/RSS20Parser.java
@@ -47,8 +47,6 @@ public class RSS20Parser extends RSS094Parser {
@Override
protected Description parseItemDescription(final Element rssRoot, final Element eDesc) {
final Description desc = super.parseItemDescription(rssRoot, eDesc);
- desc.setType("text/html"); // change as per
- // https://rome.dev.java.net/issues/show_bug.cgi?id=26
return desc;
}
diff --git a/src/test/java/com/sun/syndication/unittest/issues/Issue137Test.java b/src/test/java/com/sun/syndication/unittest/issues/Issue137Test.java
new file mode 100644
index 0000000..6e5fd35
--- /dev/null
+++ b/src/test/java/com/sun/syndication/unittest/issues/Issue137Test.java
@@ -0,0 +1,39 @@
+package com.sun.syndication.unittest.issues;
+
+import com.sun.syndication.feed.synd.SyndFeed;
+import com.sun.syndication.unittest.FeedTest;
+
+/**
+ * Test for #137: RSS item description is not complete.
+ * @author Martin Kurz
+ *
+ */
+public class Issue137Test extends FeedTest {
+
+ public Issue137Test() {
+ super("issue137-rss.xml");
+ }
+
+ public void testDescription() throws Exception {
+ final SyndFeed feed = this.getCachedSyndFeed();
+ assertEquals("
MOE will be building 11 new primary\n"+ + " schools and upgrading another 28 existing schools from November 2009. This is the first phase of\n"+ + " MOE's plans to enhance primary school infrastructure to facilitate the transition of all primary schools\n"+ + " to a single-session model to support a higher quality primary education.
", feed.getEntries().get(0).getDescription().getValue()); + assertEquals("At the Work Plan Seminar 2009, Minister for Education\n"+ + " Dr Ng Eng Hen talked\n"+ + " about the importance of language & communication skills and growing a world-class education service\n"+ + ". He spoke of strengthening the teaching track and of a teacher-driven culture of professional excellence.
", feed.getEntries().get(1).getDescription().getValue()); + assertEquals("A total of 275 schools will receive 580 Special and Level\n"+ + " Two Awards this year under the MOE Masterplan of Awards. These awards will be presented at the 2009\n"+ + " MOE Work Plan Seminar on 17 Sep 09 by the Minister for Education, Dr Ng Eng Hen.
", feed.getEntries().get(2).getDescription().getValue()); + } + +} diff --git a/src/test/resources/issue137-rss.xml b/src/test/resources/issue137-rss.xml new file mode 100644 index 0000000..a4b541b --- /dev/null +++ b/src/test/resources/issue137-rss.xml @@ -0,0 +1,80 @@ + +