Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: umlaute in RSS #1755

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/server/api/routers/rss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ const rssFeedResultObjectSchema = z
title: z.string(),
content: z.string(),
pubDate: z.string().optional(),
})
}),
),
}),
})
}),
);

export const rssRouter = createTRPCRouter({
Expand All @@ -52,7 +52,7 @@ export const rssRouter = createTRPCRouter({
widgetId: z.string().uuid(),
feedUrls: z.array(z.string()),
configName: z.string(),
})
}),
)
.output(z.array(rssFeedResultObjectSchema))
.query(async ({ input }) => {
Expand All @@ -75,8 +75,8 @@ export const rssRouter = createTRPCRouter({

const result = await Promise.all(
input.feedUrls.map(async (feedUrl) =>
getFeedUrl(feedUrl, rssWidget.properties.dangerousAllowSanitizedItemContent)
)
getFeedUrl(feedUrl, rssWidget.properties.dangerousAllowSanitizedItemContent),
),
);

return result;
Expand Down Expand Up @@ -106,11 +106,11 @@ const getFeedUrl = async (feedUrl: string, dangerousAllowSanitizedItemContent: b
title: item.title ? decode(item.title) : undefined,
content: processItemContent(
item['content:encoded'] ?? item.content,
dangerousAllowSanitizedItemContent
dangerousAllowSanitizedItemContent,
),
enclosure: createEnclosure(item),
link: createLink(item),
})
}),
)
.sort((a: { pubDate: number }, b: { pubDate: number }) => {
if (!a.pubDate || !b.pubDate) {
Expand Down Expand Up @@ -159,7 +159,9 @@ const processItemContent = (content: string, dangerousAllowSanitizedItemContent:
});
}

return encode(content);
return encode(content, {
level: "html5"
});
};

const createLink = (item: any) => {
Expand Down
Loading