fix: harden automatic mobile boards

This commit is contained in:
ajnart committed 2026-08-13 19:55:17 +02:00
1 parent 5454bcc8ac
commit 967ed8dd73
25 files changed
+490 -92

No files matched your search

+3 -2
View File
@@ -43,11 +43,13 @@ export function WidgetDataState({ children, hasWarning }: WidgetDataStateProps)
return (
<Box pos="relative" h="100%" w="100%">
{children}
{hasWarning && (
<Tooltip label={label} position="left" withArrow>
<Tooltip label={label} position="left" withArrow events={{ hover: true, focus: true, touch: true }}>
<Center
component="output"
aria-label={label}
tabIndex={0}
pos="absolute"
bottom={4}
w={28}
@@ -67,7 +69,6 @@ export function WidgetDataState({ children, hasWarning }: WidgetDataStateProps)
</Center>
</Tooltip>
)}
{children}
</Box>
);
}
@@ -0,0 +1,12 @@
import { describe, expect, test } from "vitest";
import { sanitizeFeedDescription } from "./sanitize-description";
describe("sanitizeFeedDescription", () => {
test("keeps basic formatting while removing executable markup", () => {
const description =
'<p onclick="alert(1)" aria-hidden="true" data-tracking="yes">News <strong>today</strong><script>alert(2)</script><img src="tracker"></p>';
expect(sanitizeFeedDescription(description)).toBe("<p>News <strong>today</strong></p>");
});
});
@@ -0,0 +1,11 @@
import { sanitize } from "isomorphic-dompurify";
const allowedDescriptionTags = ["b", "br", "em", "i", "li", "ol", "p", "s", "strong", "u", "ul"];
export const sanitizeFeedDescription = (description: string) =>
sanitize(description, {
ALLOW_ARIA_ATTR: false,
ALLOW_DATA_ATTR: false,
ALLOWED_ATTR: [],
ALLOWED_TAGS: allowedDescriptionTags,
});