From 8d4a76c5bf10feab55b95d46fe8a4e5118afbcd0 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 24 Sep 2026 16:35:33 -0700 Subject: [PATCH] ignore negative maxItems --- src/widgets/feed/proxy.js | 3 ++- src/widgets/feed/proxy.test.js | 10 ++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/widgets/feed/proxy.js b/src/widgets/feed/proxy.js index de54f645f..56f716874 100644 --- a/src/widgets/feed/proxy.js +++ b/src/widgets/feed/proxy.js @@ -51,7 +51,8 @@ export default async function feedProxyHandler(req, res) { cache.put(cacheKey, items, CACHE_MS); } - const maxItems = parseInt(widget.maxItems, 10) || 5; + const limit = parseInt(widget.maxItems, 10); + const maxItems = limit > 0 ? limit : 5; const showImages = widget.images !== false && widget.images !== "false"; return res.status(200).json({ diff --git a/src/widgets/feed/proxy.test.js b/src/widgets/feed/proxy.test.js index 3c86ef70c..30b4e9467 100644 --- a/src/widgets/feed/proxy.test.js +++ b/src/widgets/feed/proxy.test.js @@ -79,6 +79,16 @@ describe("widgets/feed/proxy", () => { }); }); + it.each([-1, 0, "abc"])("falls back to 5 items for maxItems %j", async (maxItems) => { + getServiceWidget.mockResolvedValue({ type: "feed", url: "https://example.com/feed.xml", maxItems }); + httpProxy.mockResolvedValueOnce([200, "application/rss+xml", Buffer.from(feed)]); + + const res = createMockRes(); + await feedProxyHandler(req, res); + + expect(res.body.items).toHaveLength(5); + }); + it("respects maxItems and drops images when disabled", async () => { getServiceWidget.mockResolvedValue({ type: "feed",