mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-27 09:43:06 +00:00
Improve string handling around trim()
trim() would always return a string, even with null as input Keep the strval to make visible that this gets unsafe input Change-Id: I6ff0ce307f6a8ac21669d6db693e5ff27767a55d
This commit is contained in:
parent
dfee99db2e
commit
a892ae21f7
|
@ -782,9 +782,9 @@ class CategoryTree {
|
|||
* @return null|Title
|
||||
*/
|
||||
public static function makeTitle( $title ) {
|
||||
$title = trim( $title );
|
||||
$title = trim( strval( $title ) );
|
||||
|
||||
if ( strval( $title ) === '' ) {
|
||||
if ( $title === '' ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,10 +76,10 @@ class CategoryTreePage extends SpecialPage {
|
|||
$this->addHelpLink( 'Extension:CategoryTree' );
|
||||
$request = $this->getRequest();
|
||||
if ( $par ) {
|
||||
$this->target = $par;
|
||||
$this->target = trim( $par );
|
||||
} else {
|
||||
$this->target = $request->getVal( 'target' );
|
||||
if ( $this->target === null ) {
|
||||
$this->target = trim( $request->getVal( 'target', '' ) );
|
||||
if ( $this->target !== '' ) {
|
||||
$rootcategory = $this->msg( 'rootcategory' );
|
||||
if ( $rootcategory->exists() ) {
|
||||
$this->target = $rootcategory->text();
|
||||
|
@ -87,8 +87,6 @@ class CategoryTreePage extends SpecialPage {
|
|||
}
|
||||
}
|
||||
|
||||
$this->target = trim( $this->target );
|
||||
|
||||
$options = [];
|
||||
$config = $this->getConfig();
|
||||
|
||||
|
@ -110,7 +108,7 @@ class CategoryTreePage extends SpecialPage {
|
|||
|
||||
$this->executeInputForm();
|
||||
|
||||
if ( $this->target !== '' && $this->target !== null ) {
|
||||
if ( $this->target !== '' ) {
|
||||
CategoryTree::setHeaders( $output );
|
||||
|
||||
$title = CategoryTree::makeTitle( $this->target );
|
||||
|
|
Loading…
Reference in a new issue