feat: Implement secure static file serving with path traversal protection and XSS prevention for template titles.
This commit is contained in:
17
src/web/utils/html.test.ts
Normal file
17
src/web/utils/html.test.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
import { describe, expect, it } from "bun:test";
|
||||
import { escapeHtml } from "./html";
|
||||
|
||||
describe("HTML Utils", () => {
|
||||
it("should escape special characters", () => {
|
||||
const unsafe = '<script>alert("xss")</script>';
|
||||
const safe = escapeHtml(unsafe);
|
||||
expect(safe).toBe("<script>alert("xss")</script>");
|
||||
});
|
||||
|
||||
it("should handle mixed content", () => {
|
||||
const unsafe = 'Hello & "World"';
|
||||
const safe = escapeHtml(unsafe);
|
||||
expect(safe).toBe("Hello & "World"");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user