jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/363994 )

Change subject: Use Sanitizer::stripAllTags( $x ) instead of 
html_entity_decode( strip_tags( $x ) )
......................................................................


Use Sanitizer::stripAllTags( $x ) instead of html_entity_decode( strip_tags( $x 
) )

MW core has a utility function for this, let's use it.

Change-Id: Ic0d86f2df92a38b2b0ff5de83c067340d47cc402
---
M includes/Conversion/Utils.php
M includes/Templating.php
M tests/phpunit/api/ApiFlowEditHeaderTest.php
M tests/phpunit/api/ApiFlowEditPostTest.php
M tests/phpunit/api/ApiFlowEditTopicSummaryTest.php
M tests/phpunit/api/ApiFlowReplyTest.php
M tests/phpunit/api/ApiFlowViewHeaderTest.php
7 files changed, 14 insertions(+), 8 deletions(-)

Approvals:
  Esanders: Looks good to me, but someone else must approve
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/Conversion/Utils.php b/includes/Conversion/Utils.php
index c109463..9ba0018 100644
--- a/includes/Conversion/Utils.php
+++ b/includes/Conversion/Utils.php
@@ -70,7 +70,7 @@
                /** @var Language $wgLang */
                global $wgLang;
 
-               $plain = trim( html_entity_decode( strip_tags( $html ), 
ENT_QUOTES ) );
+               $plain = trim( Sanitizer::stripAllTags( $html ) );
 
                if ( $truncateLength === null ) {
                        return $plain;
diff --git a/includes/Templating.php b/includes/Templating.php
index d7421ad..a0f79d1 100644
--- a/includes/Templating.php
+++ b/includes/Templating.php
@@ -10,6 +10,7 @@
 use Flow\Model\PostRevision;
 use Flow\Parsoid\ContentFixer;
 use OutputPage;
+use Sanitizer;
 // These don't really belong here
 use Linker;
 
@@ -158,7 +159,7 @@
 
                        $content = wfMessage( 'flow-stub-post-content' 
)->parse();
                        if ( !in_array( $format, [ 'html', 'fixed-html' ] ) ) {
-                               $content = strip_tags( $content );
+                               $content = Sanitizer::stripAllTags( $content );
                        }
                }
 
diff --git a/tests/phpunit/api/ApiFlowEditHeaderTest.php 
b/tests/phpunit/api/ApiFlowEditHeaderTest.php
index 21c90b1..8669424 100644
--- a/tests/phpunit/api/ApiFlowEditHeaderTest.php
+++ b/tests/phpunit/api/ApiFlowEditHeaderTest.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Flow\Tests\Api;
+use Sanitizer;
 
 /**
  * @group Flow
@@ -60,7 +61,7 @@
                $this->assertEquals( 'create-header', $revision['changeType'], 
$debug );
                $this->assertEquals(
                        '(._.)',
-                       trim( strip_tags( $revision['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$revision['content']['content'] ) ),
                        $debug
                );
                $this->assertEquals( 'html', $revision['content']['format'], 
$debug );
diff --git a/tests/phpunit/api/ApiFlowEditPostTest.php 
b/tests/phpunit/api/ApiFlowEditPostTest.php
index 151331e..0b2b7ac 100644
--- a/tests/phpunit/api/ApiFlowEditPostTest.php
+++ b/tests/phpunit/api/ApiFlowEditPostTest.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Flow\Tests\Api;
+use Sanitizer;
 
 /**
  * @group Flow
@@ -42,7 +43,7 @@
                $this->assertEquals( 'edit-post', $revision['changeType'], 
$debug );
                $this->assertEquals(
                        '⎛ ゚∩゚⎞⎛ ⍜⌒⍜⎞⎛ ゚⌒゚⎞',
-                       trim( strip_tags( $revision['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$revision['content']['content'] ) ),
                        $debug
                );
                $this->assertEquals( 'html', $revision['content']['format'], 
$debug );
diff --git a/tests/phpunit/api/ApiFlowEditTopicSummaryTest.php 
b/tests/phpunit/api/ApiFlowEditTopicSummaryTest.php
index 439cf31..a89467f 100644
--- a/tests/phpunit/api/ApiFlowEditTopicSummaryTest.php
+++ b/tests/phpunit/api/ApiFlowEditTopicSummaryTest.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Flow\Tests\Api;
+use Sanitizer;
 
 /**
  * @group Flow
@@ -39,7 +40,7 @@
                $this->assertEquals( 'create-topic-summary', 
$revision['changeType'], $debug );
                $this->assertEquals(
                        $summaryText,
-                       trim( strip_tags( $revision['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$revision['content']['content'] ) ),
                        $debug
                );
                $this->assertEquals( 'html', $revision['content']['format'], 
$debug );
@@ -57,7 +58,7 @@
 
                $this->assertEquals(
                        $summaryText,
-                       trim( strip_tags( 
$topicRevision['summary']['revision']['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$topicRevision['summary']['revision']['content']['content'] ) ),
                        'Summary content present with correct structure in 
view-topic response'
                );
        }
diff --git a/tests/phpunit/api/ApiFlowReplyTest.php 
b/tests/phpunit/api/ApiFlowReplyTest.php
index c08c534..e45d9d1 100644
--- a/tests/phpunit/api/ApiFlowReplyTest.php
+++ b/tests/phpunit/api/ApiFlowReplyTest.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Flow\Tests\Api;
+use Sanitizer;
 
 /**
  * @group Flow
@@ -41,7 +42,7 @@
                $this->assertEquals( 'reply', $revision['changeType'], $debug );
                $this->assertEquals(
                        '⎛ ゚∩゚⎞⎛ ⍜⌒⍜⎞⎛ ゚⌒゚⎞',
-                       trim( strip_tags( $revision['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$revision['content']['content'] ) ),
                        $debug
                );
                $this->assertEquals( 'html', $revision['content']['format'], 
$debug );
diff --git a/tests/phpunit/api/ApiFlowViewHeaderTest.php 
b/tests/phpunit/api/ApiFlowViewHeaderTest.php
index 3235739..f686036 100644
--- a/tests/phpunit/api/ApiFlowViewHeaderTest.php
+++ b/tests/phpunit/api/ApiFlowViewHeaderTest.php
@@ -1,6 +1,7 @@
 <?php
 
 namespace Flow\Tests\Api;
+use Sanitizer;
 
 /**
  * @group Flow
@@ -60,7 +61,7 @@
                $this->assertArrayHasKey( 'content', $revision['content'], 
$debug );
                $this->assertEquals(
                        'swimmingly',
-                       trim( strip_tags( $revision['content']['content'] ) ),
+                       trim( Sanitizer::stripAllTags( 
$revision['content']['content'] ) ),
                        $debug
                );
                $this->assertArrayHasKey( 'format', $revision['content'], 
$debug );

-- 
To view, visit https://gerrit.wikimedia.org/r/363994
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0d86f2df92a38b2b0ff5de83c067340d47cc402
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Catrope <r...@wikimedia.org>
Gerrit-Reviewer: Esanders <esand...@wikimedia.org>
Gerrit-Reviewer: Jforrester <jforres...@wikimedia.org>
Gerrit-Reviewer: Krinkle <krinklem...@gmail.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to