D3r1ck01 has uploaded a new change for review.
https://gerrit.wikimedia.org/r/278557
Change subject: Trimming leading and trailing spaces via Special:NewItem
......................................................................
Trimming leading and trailing spaces via 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 before sending them
for hasSufficientArguments() check. 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, 8 insertions(+), 10 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase
refs/changes/57/278557/1
diff --git a/repo/includes/Specials/SpecialNewEntity.php
b/repo/includes/Specials/SpecialNewEntity.php
index bd7a42b..39bfc02 100644
--- a/repo/includes/Specials/SpecialNewEntity.php
+++ b/repo/includes/Specials/SpecialNewEntity.php
@@ -164,17 +164,19 @@
/**
* Tries to extract argument values from web request or of the page's
sub-page parts
*
+ * Trims label and description from the web request
+ *
* @since 0.1
*/
protected function prepareArguments() {
- $this->label = $this->getRequest()->getVal(
+ $this->label = $this->stringNormalizer->trimWhitespace(
$this->getRequest()->getVal(
'label',
isset( $this->parts[0] ) ? $this->parts[0] : ''
- );
- $this->description = $this->getRequest()->getVal(
+ ) );
+ $this->description = $this->stringNormalizer->trimWhitespace(
$this->getRequest()->getVal(
'description',
isset( $this->parts[1] ) ? $this->parts[1] : ''
- );
+ ) );
$aliases = $this->getRequest()->getVal( 'aliases' );
$this->aliases = ( $aliases === null ? array() : explode( '|',
$aliases ) );
$this->contentLanguage = Language::factory(
$this->getRequest()->getVal(
@@ -191,12 +193,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: newchange
Gerrit-Change-Id: I7ff02dbe520dc3328eba7c872eb69e181c3f70da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: D3r1ck01 <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits