[MediaWiki-commits] [Gerrit] mediawiki...Flow[master]: Use Sanitizer::stripAllTags( $x ) instead of html_entity_dec...

2017-07-10 Thread jenkins-bot (Code Review)
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 @@
 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 @@
 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 @@
 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 @@
 assertEquals( 'reply', 

[MediaWiki-commits] [Gerrit] mediawiki...Flow[master]: Use Sanitizer::stripAllTags( $x ) instead of html_entity_dec...

2017-07-07 Thread Catrope (Code Review)
Catrope has uploaded a new change for review. ( 
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, 13 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/94/363994/1

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..fa8dd06 100644
--- a/includes/Templating.php
+++ b/includes/Templating.php
@@ -158,7 +158,7 @@
 
$content = wfMessage( 'flow-stub-post-content' 
)->parse();
if ( !in_array( $format, [ 'html', 'fixed-html' ] ) ) {
-   $content = strip_tags( $content );
+   $content = Santiizer::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 @@
 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 @@
 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 @@
 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 @@
 assertEquals( 'reply', $revision['changeType'], $debug );
$this->assertEquals(
'⎛ ゚∩゚⎞⎛ ⍜⌒⍜⎞⎛ ゚⌒゚⎞',
-   trim( strip_tags( $revision['content']['content'] ) ),
+