diff --git a/webapp/tests/Unit/Utils/UtilsTest.php b/webapp/tests/Unit/Utils/UtilsTest.php index 15d60d8efb9..f45cb13d946 100644 --- a/webapp/tests/Unit/Utils/UtilsTest.php +++ b/webapp/tests/Unit/Utils/UtilsTest.php @@ -713,6 +713,54 @@ public function provideTestGetImageSize(): Generator yield [__DIR__ . '/../../../public/images/DOMjudgelogo.svg', 510, 1122]; } + public function testSanitizeSvg(): void + { + $dirty = << + + + + + + + + + + + + + + + + + test 1 + test 2 + test 3 + test 4 + + test 5 + test 6 + + + + + + + + shouldn't be here + + + + + EOF; + $clean = Utils::sanitizeSvg($dirt); + self::assert(!str_contains($clean, "script")); + self::assert(!str_contains($clean, "alert")); + self::assert(!str_contains($clean, "shouldn't be here")); + self::assert(!str_contains($clean, "example.com")); + self::assert(str_contains($clean, '')); + } + /** * Test that the wrapUnquoted function returns the correct result */