diff --git a/chrome/content/zotero/xpcom/feedReader.js b/chrome/content/zotero/xpcom/feedReader.js index 8cf45063f8..50d590f29d 100644 --- a/chrome/content/zotero/xpcom/feedReader.js +++ b/chrome/content/zotero/xpcom/feedReader.js @@ -416,23 +416,23 @@ Zotero.FeedReader._getFeedItem = function (feedEntry, feedInfo) { if (feedEntry.title) item.title = Zotero.FeedReader._getRichText(feedEntry.title, 'title'); - if (feedEntry.summary) { - let summaryFragment = feedEntry.summary.createDocumentFragment(); - if (summaryFragment.querySelectorAll('body').length === 1) { - summaryFragment.replaceChildren(...summaryFragment.querySelector('body').childNodes); - } - item.abstractNote = new XMLSerializer().serializeToString(summaryFragment); - - if (!item.title) { - // We will probably have to trim this, so let's use plain text to - // avoid splitting inside some markup - let title = Zotero.Utilities.trimInternal(feedEntry.summary.plainText()); - let splitAt = title.lastIndexOf(' ', 50); - if (splitAt == -1) splitAt = 50; - - item.title = title.substr(0, splitAt); - if (splitAt <= title.length) item.title += '...'; + if (feedEntry.content || feedEntry.summary) { + let abstractFragment = (feedEntry.content || feedEntry.summary).createDocumentFragment(); + if (abstractFragment.querySelectorAll('body').length === 1) { + abstractFragment.replaceChildren(...abstractFragment.querySelector('body').childNodes); } + item.abstractNote = new XMLSerializer().serializeToString(abstractFragment); + } + + if (feedEntry.summary && !item.title) { + // We will probably have to trim this, so let's use plain text to + // avoid splitting inside some markup + let title = Zotero.Utilities.trimInternal(feedEntry.summary.plainText()); + let splitAt = title.lastIndexOf(' ', 50); + if (splitAt == -1) splitAt = 50; + + item.title = title.substr(0, splitAt); + if (splitAt <= title.length) item.title += '...'; } if (feedEntry.link) item.url = feedEntry.link.href; diff --git a/test/tests/data/feedRichText.rss b/test/tests/data/feedRichText.rss index dd1073b595..d129a95432 100644 --- a/test/tests/data/feedRichText.rss +++ b/test/tests/data/feedRichText.rss @@ -1,6 +1,6 @@ - + Liftoff News http://liftoff.msfc.nasa.gov/ @@ -26,5 +26,13 @@ Tue, 27 May 2003 08:37:32 GMT http://liftoff.msfc.nasa.gov/2003/05/27.html#item571 + + This item has content + https://onlinelibrary.wiley.com/journal/27314375?af=R + This description has no tags in it. + This content has <blink>tags</blink> in it. + Tue, 23 Apr 2024 00:38:38 -0700 + 10.1002/dro2.121 + diff --git a/test/tests/feedReaderTest.js b/test/tests/feedReaderTest.js index 347c73506e..17fade4e06 100644 --- a/test/tests/feedReaderTest.js +++ b/test/tests/feedReaderTest.js @@ -217,6 +217,18 @@ describe("Zotero.FeedReader", function () { assert.equal(item.title, "Embedded tags"); }); + it('should use content as abstractNote when available', async () => { + const fr = new Zotero.FeedReader(richTextRSSFeedURL); + await fr.process(); + const itemIterator = new fr.ItemIterator(); + let item; + for (let i = 0; i < 3; i++) { + item = await itemIterator.next().value; + } + + assert.include(item.abstractNote, ' { const fr = new Zotero.FeedReader(richTextRSSFeedURL); await fr.process(); @@ -227,7 +239,6 @@ describe("Zotero.FeedReader", function () { item = await itemIterator.next().value; } - // The entry description is XHTML, so tags are removed there. assert.equal(item.abstractNote, 'The proposed VASIMR engine would do that.'); });