21require_once(
'./libs/composer/vendor/autoload.php');
23use PHPUnit\Framework\TestCase;
37 '<svg width="100" height="100">
38 <foreignObject width="100%" height="100%">
39 <script>alert(document.domain);</script>
45 '<svg width="100" height="100">
46 <foreignObject width="100%" height="100%" onclick="alert(document.domain);">
53 '<svg version="1.1" baseProfile="full"
54xmlns="http://www.w3.org/2000/svg">
55<rect width="100" height="100" style="fill:rgb(0,0,255);" />
56<script type="text/javascript">
57alert("XSS in SVG on " + document.domain );
63 '<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
64<use xlink:href="data:application/xml;base64 ,
65PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5r
66PSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIj4KPGRlZnM+CjxjaXJjbGUgaWQ9InRlc3QiIHI9I
67jUwIiBjeD0iMTAwIiBjeT0iMTAwIiBzdHlsZT0iZmlsbDogI0YwMCI+CjxzZXQgYXR0cmlidXRlTm
68FtZT0iZmlsbCIgYXR0cmlidXRlVHlwZT0iQ1NTIiBvbmJlZ2luPSdhbGVydChkb2N1bWVudC5jb29r
69aWUpJwpvbmVuZD0nYWxlcnQoIm9uZW5kIiknIHRvPSIjMDBGIiBiZWdpbj0iMXMiIGR1cj0iNXMiIC
708+CjwvY2lyY2xlPgo8L2RlZnM+Cjx1c2UgeGxpbms6aHJlZj0iI3Rlc3QiLz4KPC9zdmc+#test"/>
84 $metadata =
new Metadata(
'test.svg', 100,
'image/svg+xml');
86 $result = $preProcessor->process($stream, $metadata);
90 $this->assertSame(
'The SVG file contains malicious code. (' .
$type .
').',
$result->getMessage());
95 $svg =
'<svg version="1.1" baseProfile="full"
96xmlns="http://www.w3.org/2000/svg">
97<rect width="100" height="100" style="fill:rgb(0,0,255);" />
102 $metadata =
new Metadata(
'test.svg', 100,
'image/svg+xml');
104 $result = $preProcessor->process($stream, $metadata);
108 $this->assertSame(
'SVG OK',
$result->getMessage());
114 [
'./templates/default/images/bigplay.svg'],
115 [
'./templates/default/images/jstree.svg'],
116 [
'./templates/default/images/loader.svg'],
117 [
'./templates/default/images/col.svg'],
118 [
'./templates/default/images/HeaderIcon.svg'],
119 [
'./templates/default/images/answered_not.svg'],
128 $this->assertTrue(file_exists($path));
129 $svg = file_get_contents($path);
133 $metadata =
new Metadata(
'bigplay.svg', 100,
'image/svg+xml');
135 $result = $preProcessor->process($stream, $metadata);
137 $this->assertSame(
'SVG OK',
$result->getMessage());
An exception for terminatinating execution or to throw for unit testing.
const REJECTED
Upload got rejected by a processor.
const DENIED
Upload got denied by a processor, the upload will be removed immediately.
Class SVGBlacklistPreProcessor.
Class SVGPreProcessorTest.
testMaliciousSVG(string $malicious_svg, string $type)
@dataProvider maliciousSVGProvider
testSomeComplexSaneSVG(string $path)
@dataProvider provideSomeComplexSaneSVG
provideSomeComplexSaneSVG()
Class Streams Stream factory which enables the user to create streams without the knowledge of the co...
static ofString($string)
Creates a new stream with an initial value.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...