only try http(s) urls

This commit is contained in:
shamoon
2026-09-24 16:33:56 -07:00
parent df52670871
commit 4b8c5a91e7
2 changed files with 10 additions and 5 deletions
+4 -5
View File
@@ -1,6 +1,6 @@
import cache from "memory-cache";
import { parseFeed } from "./utils";
import { httpUrl, parseFeed } from "./utils";
import getServiceWidget from "utils/config/service-helpers";
import createLogger from "utils/logger";
@@ -18,12 +18,11 @@ export default async function feedProxyHandler(req, res) {
return res.status(400).json({ error: "Missing feed URL" });
}
let url;
try {
url = new URL(widget.url);
} catch {
const href = httpUrl(widget.url);
if (!href) {
return res.status(400).json({ error: "Invalid feed URL" });
}
const url = new URL(href);
const cacheKey = `feed:${url.href}`;
let items = cache.get(cacheKey);
+6
View File
@@ -52,6 +52,12 @@ describe("widgets/feed/proxy", () => {
await feedProxyHandler(req, res);
expect(res.statusCode).toBe(400);
expect(res.body).toEqual({ error: "Invalid feed URL" });
getServiceWidget.mockResolvedValueOnce({ type: "feed", url: "file:///etc/passwd" });
res = createMockRes();
await feedProxyHandler(req, res);
expect(res.statusCode).toBe(400);
expect(res.body).toEqual({ error: "Invalid feed URL" });
expect(httpProxy).not.toHaveBeenCalled();
});