jenkins-bot has submitted this change and it was merged. Change subject: Trimming leading and trailing spaces in Special:NewItem ......................................................................
Trimming leading and trailing spaces in Special:NewItem * hasSufficientArguments() was not trimming 'label' and 'description' but now the whitespaces trimming function was called in prepareArguments() which trimmed all the arguments from the web request. Trimming now is working for label, description and aliases. * Also, the hasSufficientArguments() has been revised and trimming functions removed and transfered to prepareArguments() since it didn't work for label and description. Bug: T130459 Change-Id: I7ff02dbe520dc3328eba7c872eb69e181c3f70da --- M repo/includes/Specials/SpecialNewEntity.php 1 file changed, 16 insertions(+), 9 deletions(-) Approvals: Hoo man: Looks good to me, approved jenkins-bot: Verified diff --git a/repo/includes/Specials/SpecialNewEntity.php b/repo/includes/Specials/SpecialNewEntity.php index bd7a42b..83654d7 100644 --- a/repo/includes/Specials/SpecialNewEntity.php +++ b/repo/includes/Specials/SpecialNewEntity.php @@ -164,19 +164,30 @@ /** * Tries to extract argument values from web request or of the page's sub-page parts * + * Trimming argument values from web request. + * * @since 0.1 */ protected function prepareArguments() { - $this->label = $this->getRequest()->getVal( + $label = $this->getRequest()->getVal( 'label', isset( $this->parts[0] ) ? $this->parts[0] : '' ); - $this->description = $this->getRequest()->getVal( + $this->label = $this->stringNormalizer->trimToNFC( $label ); + + $description = $this->getRequest()->getVal( 'description', isset( $this->parts[1] ) ? $this->parts[1] : '' ); + $this->description = $this->stringNormalizer->trimToNFC( $description ); + $aliases = $this->getRequest()->getVal( 'aliases' ); - $this->aliases = ( $aliases === null ? array() : explode( '|', $aliases ) ); + $explodedAliases = ( $aliases === null ? array() : explode( '|', $aliases ) ); + foreach ( $explodedAliases as $alias ) { + if ( $alias !== '' ) { + $this->aliases[] = $this->stringNormalizer->trimToNFC( $alias ); + } + } $this->contentLanguage = Language::factory( $this->getRequest()->getVal( 'lang', $this->getLanguage()->getCode() @@ -191,12 +202,8 @@ * @return bool */ protected function hasSufficientArguments() { - return $this->stringNormalizer->trimWhitespace( $this->label ) !== '' - || $this->stringNormalizer->trimWhitespace( $this->description ) !== '' - || implode( '', array_map( - array( $this->stringNormalizer, 'trimWhitespace' ), - $this->aliases - ) ) !== ''; + return $this->label !== '' || $this->description !== '' + || implode( '', $this->aliases ) !== ''; } /** -- To view, visit https://gerrit.wikimedia.org/r/278557 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I7ff02dbe520dc3328eba7c872eb69e181c3f70da Gerrit-PatchSet: 15 Gerrit-Project: mediawiki/extensions/Wikibase Gerrit-Branch: master Gerrit-Owner: D3r1ck01 <alangider...@gmail.com> Gerrit-Reviewer: Addshore <addshorew...@gmail.com> Gerrit-Reviewer: Bene <benestar.wikime...@gmail.com> Gerrit-Reviewer: Hoo man <h...@online.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits