jenkins-bot has submitted this change and it was merged.

Change subject: Fix double escaping in special:log/gwtoolset
......................................................................


Fix double escaping in special:log/gwtoolset

Note the <a> tag (from calling ->parse on the message) in
https://commons.wikimedia.org/?title=Special:Log&offset=20150724115413&type=gwtoolset&user=Jason.nlw&limit=2

Note the surounding of things by < > in
https://commons.wikimedia.org/?title=Special:Log&type=gwtoolset&user=Jason.nlw&offset=20150724122545&limit=1
caused by giving status::newFatal the results of wfMessage( .. )->text()
instead of the message name like its supposed to take.

Ideally this would be modified to have the messages expanded by
the log handler (Like newstyle logs), but that's a much larger
change, and I'd first like to just get the escaped html out
of the log view.

Bug: T87044
Change-Id: I72123fde8e8aad9401ca861f057acd946f1c8d93
---
M includes/GWTException.php
M includes/Handlers/UploadHandler.php
M includes/Helpers/GWTFileBackend.php
3 files changed, 19 insertions(+), 32 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/GWTException.php b/includes/GWTException.php
index 8875c82..9c7874a 100644
--- a/includes/GWTException.php
+++ b/includes/GWTException.php
@@ -44,14 +44,16 @@
 
                if ( is_array( $message ) ) {
                        foreach ( $message as $key => $params ) {
-                               $result .= wfMessage( $key )->params( $params 
)->parse();
+                               $result .= wfMessage( $key )->params( $params 
)->text();
                        }
-               } else if ( strpos( $message, 'gwtoolset-' ) !== false ) {
-                       $result .= wfMessage( $message )->parse();
+               } else if ( strpos( $message, 'gwtoolset-' ) === 0 ) {
+                       $result .= wfMessage( $message )->text();
                } else {
-                       $result = Sanitizer::removeHTMLtags( $message );
+                       $result = $message;
                }
 
+               $result = Sanitizer::removeHTMLtags( $result );
+
                return $result;
        }
 
diff --git a/includes/Handlers/UploadHandler.php 
b/includes/Handlers/UploadHandler.php
index 926008c..2191d4b 100644
--- a/includes/Handlers/UploadHandler.php
+++ b/includes/Handlers/UploadHandler.php
@@ -244,24 +244,18 @@
                        if ( $warnings['exists']['warning'] === 'exists' ) {
                                // check if another contributor has altered 
this title
                                if ( $this->otherContributors( $title ) ) {
-                                       $msg =
-                                               wfMessage( 
'gwtoolset-mediafile-other-contributors' )
-                                                       ->params( 
$warnings['exists']['file']->getTitle() )
-                                                       ->text();
-
-                                       $status = Status::newFatal( $msg );
+                                       $status = Status::newFatal( 
'gwtoolset-mediafile-other-contributors',
+                                               
$warnings['exists']['file']->getTitle()
+                                       );
 
                                // this title’s most recent mediafile is the 
same as the one being uploaded
                                } else if (
                                        $upload->getTempFileSha1Base36() ===
                                        $warnings['exists']['file']->getSha1()
                                ) {
-                                       $msg =
-                                               wfMessage( 
'gwtoolset-mediafile-duplicate-same-title' )
-                                                       ->params( 
$warnings['exists']['file']->getTitle() )
-                                                       ->text();
-
-                                       $status = Status::newFatal( $msg );
+                                       $status = Status::newFatal( 
'gwtoolset-mediafile-duplicate-same-title',
+                                               
$warnings['exists']['file']->getTitle()
+                                       );
                                }
                        }
                }
@@ -272,12 +266,9 @@
                        && isset( $warnings['duplicate'] )
                        && count( $warnings['duplicate'] ) > 0
                ) {
-                       $msg =
-                               wfMessage( 
'gwtoolset-mediafile-duplicate-another-title' )
-                                       ->params( 
$warnings['duplicate'][0]->getTitle() )
-                                       ->text();
-
-                       $status = Status::newFatal( $msg );
+                       $status = Status::newFatal( 
'gwtoolset-mediafile-duplicate-another-title',
+                               $warnings['duplicate'][0]->getTitle()
+                       );
                }
 
                return $status;
@@ -713,12 +704,7 @@
                                                $this->_User
                                        );
                                } else {
-                                       $msg =
-                                               wfMessage( 
'gwtoolset-mediafile-other-contributors' )
-                                                       ->params( $Title )
-                                                       ->escaped();
-
-                                       $Status = Status::newFatal( $msg );
+                                       $Status = Status::newFatal( 
'gwtoolset-mediafile-other-contributors', $Title );
                                }
                        }
                }
diff --git a/includes/Helpers/GWTFileBackend.php 
b/includes/Helpers/GWTFileBackend.php
index 98fc913..5e82635 100644
--- a/includes/Helpers/GWTFileBackend.php
+++ b/includes/Helpers/GWTFileBackend.php
@@ -96,9 +96,8 @@
                        JobQueueGroup::singleton()->push( $job );
                } catch ( Exception $e ) {
                        return Status::newFatal(
-                               wfMessage( 
'gwtoolset-batchjob-creation-failure' )
-                                       ->params( 'GWTFileBackendCleanupJob' )
-                                       ->parse()
+                               'gwtoolset-batchjob-creation-failure',
+                               'GWTFileBackendCleanupJob'
                        );
                }
 
@@ -126,7 +125,7 @@
                if ( $this->FileBackend->fileExists( $src ) ) {
                        $result = $this->FileBackend->quickDelete( $src );
                } else {
-                       $result = Status::newFatal( wfMessage( 
'gwtoolset-delete-no-file' ) );
+                       $result = Status::newFatal( 'gwtoolset-delete-no-file' 
);
                }
 
                return $result;

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I72123fde8e8aad9401ca861f057acd946f1c8d93
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/GWToolset
Gerrit-Branch: master
Gerrit-Owner: Brian Wolff <bawolff...@gmail.com>
Gerrit-Reviewer: Dan-nl <d_ent...@yahoo.com>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: Gilles <gdu...@wikimedia.org>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: MarkTraceur <mtrac...@member.fsf.org>
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