deno.land / x / fresh@1.1.1 / src / server / htmlescape_test.ts

htmlescape_test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import { htmlEscapeJsonString } from "./htmlescape.ts";import { assertEquals } from "../../tests/deps.ts";
Deno.test("with angle brackets should escape", () => { const evilObj = { evil: "<script></script>" }; assertEquals( htmlEscapeJsonString(JSON.stringify(evilObj)), '{"evil":"\\u003cscript\\u003e\\u003c/script\\u003e"}', );});
Deno.test("with angle brackets should parse back", () => { const evilObj = { evil: "<script></script>" }; assertEquals( JSON.parse(htmlEscapeJsonString(JSON.stringify(evilObj))), evilObj, );});
fresh

Version Info

Tagged at
a year ago