X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=tests%2Fphpunit%2Fincludes%2Fupload%2FUploadBaseTest.php;h=a42c86c3a6cdd9f4c284a2a6fd85076a8c3dcefc;hb=3635092917533a865ae94a78243caef2cd99d577;hp=3debe6e19801afc907f58a6bed273fa240fd25d0;hpb=c5f68ec77aa526dd77c9daec8f88a3f63ef75948;p=lhc%2Fweb%2Fwiklou.git diff --git a/tests/phpunit/includes/upload/UploadBaseTest.php b/tests/phpunit/includes/upload/UploadBaseTest.php index 3debe6e198..a42c86c3a6 100644 --- a/tests/phpunit/includes/upload/UploadBaseTest.php +++ b/tests/phpunit/includes/upload/UploadBaseTest.php @@ -297,31 +297,31 @@ class UploadBaseTest extends MediaWikiTestCase { ' ', true, true, - 'SVG with non-local image href (bug 65839)' + 'SVG with non-local image href (T67839)' ], [ ' 50 100 ', true, true, - 'SVG with remote stylesheet (bug 57550)' + 'SVG with remote stylesheet (T59550)' ], [ ' B ', true, true, - 'SVG with rembeded iframe (bug 60771)' + 'SVG with rembeded iframe (T62771)' ], [ ' WebPlatform.org ', true, true, - 'SVG with @import in style element (bug 69008)' + 'SVG with @import in style element (T71008)' ], [ ' WebPlatform.org ', true, true, - 'SVG with @import in style element and child element (bug 69008#c11)' + 'SVG with @import in style element and child element (T71008#c11)' ], [ ' WebPlatform.org ', @@ -333,27 +333,27 @@ class UploadBaseTest extends MediaWikiTestCase { ' ', true, true, - 'SVG with remote background image (bug 69008)' + 'SVG with remote background image (T71008)' ], [ ' ', true, true, - 'SVG with remote background image, encoded (bug 69008)' + 'SVG with remote background image, encoded (T71008)' ], [ ' ', true, true, - 'SVG with remote background image, in style element (bug 69008)' + 'SVG with remote background image, in style element (T71008)' ], [ // This currently doesn't seem to work in any browsers, but in case - // http://www.w3.org/TR/css3-images/ is implemented for SVG files + // https://www.w3.org/TR/css3-images/ is implemented for SVG files ' ', true, true, - 'SVG with remote background image using image() (bug 69008)' + 'SVG with remote background image using image() (T71008)' ], [ // As reported by Cure53 @@ -397,6 +397,46 @@ class UploadBaseTest extends MediaWikiTestCase { // @codingStandardsIgnoreEnd } + /** + * @dataProvider provideDetectScriptInSvg + */ + public function testDetectScriptInSvg( $svg, $expected, $message ) { + // This only checks some weird cases, most tests are in testCheckSvgScriptCallback() above + $result = $this->upload->detectScriptInSvg( $svg, false ); + $this->assertSame( $expected, $result, $message ); + } + + public static function provideDetectScriptInSvg() { + global $IP; + return [ + [ + "$IP/tests/phpunit/data/upload/buggynamespace-original.svg", + false, + 'SVG with a weird but valid namespace definition created by Adobe Illustrator' + ], + [ + "$IP/tests/phpunit/data/upload/buggynamespace-okay.svg", + false, + 'SVG with a namespace definition created by Adobe Illustrator and mangled by Inkscape' + ], + [ + "$IP/tests/phpunit/data/upload/buggynamespace-okay2.svg", + false, + 'SVG with a namespace definition created by Adobe Illustrator and mangled by Inkscape (twice)' + ], + [ + "$IP/tests/phpunit/data/upload/buggynamespace-bad.svg", + [ 'uploadscriptednamespace', 'i' ], + 'SVG with a namespace definition using an undefined entity' + ], + [ + "$IP/tests/phpunit/data/upload/buggynamespace-evilhtml.svg", + [ 'uploadscriptednamespace', 'http://www.w3.org/1999/xhtml' ], + 'SVG with an html namespace encoded as an entity' + ], + ]; + } + /** * @dataProvider provideCheckXMLEncodingMissmatch */ @@ -442,4 +482,11 @@ class UploadTestHandler extends UploadBase { ); return [ $check->wellFormed, $check->filterMatch ]; } + + /** + * Same as parent function, but override visibility to 'public'. + */ + public function detectScriptInSvg( $filename, $partial ) { + return parent::detectScriptInSvg( $filename, $partial ); + } }