From 5fd77aa0d7749f87e0d8f0e0761d75de78c71f58 Mon Sep 17 00:00:00 2001 From: Brad Jorsch Date: Tue, 13 Jun 2017 11:54:40 -0400 Subject: [PATCH] Update css-sanitizer to v1.0.2 Also fold a unit test into the normal function since we don't have to have two valid responses based on css-sanitizer version. Change-Id: I107c8b911781924ce9cc0730257243b9cb1592a6 --- composer.json | 2 +- tests/phpunit/TemplateStylesContentTest.php | 26 ++++----------------- 2 files changed, 5 insertions(+), 23 deletions(-) diff --git a/composer.json b/composer.json index 696138b..74a7cc5 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "license": "GPL-2.0+", "require": { "cssjanus/cssjanus": "1.2.0", - "wikimedia/css-sanitizer": "~1.0.1" + "wikimedia/css-sanitizer": "~1.0.2" }, "require-dev": { "jakub-onderka/php-parallel-lint": "0.9.2", diff --git a/tests/phpunit/TemplateStylesContentTest.php b/tests/phpunit/TemplateStylesContentTest.php index 0b32538..1e5e43b 100644 --- a/tests/phpunit/TemplateStylesContentTest.php +++ b/tests/phpunit/TemplateStylesContentTest.php @@ -77,33 +77,15 @@ class TemplateStylesContentTest extends TextContentTest { [ 'severity' => 'fatal', 'novalue' => true ], Status::newFatal( 'templatestyles-error-bad-value-for-property', 1, 27, 'font-family' ), ], - ]; - } - - /** - * @dataProvider provideHtmlInjection - * @param string $text Input text - * @param string $output Valid escaped output text - */ - public function testHtmlInjection( $text, $output ) { - $status = $this->newContent( $text )->sanitize(); - - if ( $status->isOk() ) { // css-sanitizer 1.0.2+ - $this->assertEquals( Status::newGood( $output ), $status ); - } else { // css-sanitizer 1.0.1 - $this->assertTrue( $status->hasMessage( 'templatestyles-end-tag-injection' ) ); - } - } - - public static function provideHtmlInjection() { - return [ ' in string' => [ '.foo { content: ""; }', - '.mw-parser-output .foo{content:"\3c /style\3e "}', + [], + Status::newGood( '.mw-parser-output .foo{content:"\3c /style\3e "}' ) ], ' via identifiers' => [ '.foo { grid-area: \< / style 0 / \>; }', - '.mw-parser-output .foo{grid-area:\3c /style 0/\3e }', + [], + Status::newGood( '.mw-parser-output .foo{grid-area:\3c /style 0/\3e }' ), ], ]; }