Skip to content
Open
Show file tree
Hide file tree
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
14 changes: 12 additions & 2 deletions src/components/BackToTopButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,21 @@ export default function BackToTopButton() {
}
};

const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);

useEffect(() => {
const mq = window.matchMedia("(prefers-reduced-motion: reduce)");
setPrefersReducedMotion(mq.matches);
const handler = (e: MediaQueryListEvent) => setPrefersReducedMotion(e.matches);
mq.addEventListener("change", handler);
return () => mq.removeEventListener("change", handler);
}, []);

const scrollToTop = () => {
if (typeof window !== "undefined") {
window.scrollTo({
top: 0,
behavior: "smooth",
behavior: prefersReducedMotion ? "auto" : "smooth",
});
}
};
Expand Down Expand Up @@ -70,7 +80,7 @@ export default function BackToTopButton() {
strokeDasharray={circumference}
strokeDashoffset={strokeDashoffset}
style={{ filter: "drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent))" }}
className="transition-[stroke-dashoffset] duration-100"
className={`transition-[stroke-dashoffset] duration-100 ${prefersReducedMotion ? "!transition-none" : ""}`}
/>
</svg>
<button
Expand Down
21 changes: 21 additions & 0 deletions test/ssrf-protection.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,5 +108,26 @@ describe("ssrf-protection", () => {
mockLookup.mockResolvedValue([{ address: "2001:4860:4860::8888", family: 6 }]);
expect(await isSafeUrl("http://example.com")).toBe(true);
});

it("should block 192.168.x.x as direct IP literal (regression: signed overflow #3118)", async () => {
expect(await isSafeUrl("http://192.168.1.1")).toBe(false);
expect(await isSafeUrl("http://192.168.0.1")).toBe(false);
expect(await isSafeUrl("http://192.168.255.255")).toBe(false);
});

it("should block 172.16.x.x as direct IP literal (regression: signed overflow #3118)", async () => {
expect(await isSafeUrl("http://172.16.0.1")).toBe(false);
expect(await isSafeUrl("http://172.31.255.255")).toBe(false);
});

it("should block 10.x.x.x as direct IP literal", async () => {
expect(await isSafeUrl("http://10.0.0.1")).toBe(false);
expect(await isSafeUrl("http://10.255.255.255")).toBe(false);
});

it("should block 127.x.x.x as direct IP literal", async () => {
expect(await isSafeUrl("http://127.0.0.1")).toBe(false);
expect(await isSafeUrl("http://127.255.255.255")).toBe(false);
});
});
});
Loading