/
alt3rmann
/
label-studio
Обзор
Документация
Войти
/
alt3rmann
/
label-studio
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
web/libs/editor/src/utils/__tests__/html.test.ts
40 строк
981 B
Raul Martin
refactor: echo 27: Introducing biome (#5759)
29 апр 2024, 11:39
Не верифицирован
29 апр 2024, 11:39
2660ec9
Код
Авторство
О чём код?
import { sanitizeHtml } from "../html"; const htmlSanitizeList = [ { input: '<iframe src="http://malicious.com"></iframe>', expected: "", }, { input: "<script>alert('XSS');</script>", expected: "", }, { input: "\"><img src=x onerror=alert('XSS')>", expected: '"><img src="x" />', }, { input: "<script>alert(1)</script foo='bar'>", expected: "", }, { input: "><script>alert('XSS')</script>", expected: ">", }, { input: '<?xml version="1.0" encoding="ISO-8859-1"?><foo><![CDATA[<script>alert(\'XSS\');</script>]]></foo>', expected: "<foo></foo>", }, { input: "It's a test to check if <, > and & are escaped", expected: "It's a test to check if <, > and & are escaped", }, ]; describe("Helper function html sanitize", () => { test("sanitize html list", () => { htmlSanitizeList.forEach((item) => { expect(sanitizeHtml(item.input)).toBe(item.expected); }); }); });