Aude has uploaded a new change for review. ( https://gerrit.wikimedia.org/r/344879 )
Change subject: Update Wikidata - fix term validation ...................................................................... Update Wikidata - fix term validation Change-Id: Ief7512b96cf4aa193314cec33920f28ad0dc9931 --- M composer.lock M extensions/Wikibase/lib/includes/UserInputException.php M extensions/Wikibase/repo/includes/ValidatorBuilders.php M extensions/Wikibase/repo/includes/Validators/TermValidatorFactory.php M extensions/Wikibase/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php M vendor/composer/installed.json 6 files changed, 28 insertions(+), 11 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikidata refs/changes/79/344879/1 diff --git a/composer.lock b/composer.lock index 033a9e8..c6b5970 100644 --- a/composer.lock +++ b/composer.lock @@ -1436,12 +1436,12 @@ "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "2755a3431f5a763b634c2c46d034ad34796631e0" + "reference": "0bca144964d2214aba02786e7eb4d384be926988" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/2755a3431f5a763b634c2c46d034ad34796631e0", - "reference": "2755a3431f5a763b634c2c46d034ad34796631e0", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/0bca144964d2214aba02786e7eb4d384be926988", + "reference": "0bca144964d2214aba02786e7eb4d384be926988", "shasum": "" }, "require": { @@ -1515,7 +1515,7 @@ "wikibaserepo", "wikidata" ], - "time": "2017-03-21 03:19:45" + "time": "2017-03-26 22:33:16" }, { "name": "wikibase/wikimedia-badges", diff --git a/extensions/Wikibase/lib/includes/UserInputException.php b/extensions/Wikibase/lib/includes/UserInputException.php index 8b5a881..18a5e58 100644 --- a/extensions/Wikibase/lib/includes/UserInputException.php +++ b/extensions/Wikibase/lib/includes/UserInputException.php @@ -2,6 +2,8 @@ namespace Wikibase\Lib; +use Exception; + /** * Used in special pages and elsewhere to handle user input errors, * allow them to bubble up to presentation layer and contain message @@ -12,4 +14,18 @@ */ class UserInputException extends MessageException { + /** + * @see MessageException::__construct + * + * @param string $key + * @param array $params List of parameters, depending on the message. Since this is a "user + * input" exception, callers are expected to pass in unescaped user input. This class will take + * care of proper wikitext escaping. + * @param string $message + * @param Exception|null $previous + */ + public function __construct( $key, array $params, $message, Exception $previous = null ) { + parent::__construct( $key, array_map( 'wfEscapeWikiText', $params ), $message, $previous ); + } + } diff --git a/extensions/Wikibase/repo/includes/ValidatorBuilders.php b/extensions/Wikibase/repo/includes/ValidatorBuilders.php index 31e3e91..9e193e2 100644 --- a/extensions/Wikibase/repo/includes/ValidatorBuilders.php +++ b/extensions/Wikibase/repo/includes/ValidatorBuilders.php @@ -176,7 +176,7 @@ $validators[] = new TypeValidator( 'string' ); //TODO: validate UTF8 (here and elsewhere) $validators[] = new StringLengthValidator( 1, $maxLength, 'mb_strlen' ); - $validators[] = new RegexValidator( '/^\s|[\r\n\t]|\s$/', true ); // no leading/trailing whitespace, no line breaks. + $validators[] = new RegexValidator( '/^\s|[\r\n\t]|\s$/u', true ); // no leading/trailing whitespace, no line breaks. return $validators; } diff --git a/extensions/Wikibase/repo/includes/Validators/TermValidatorFactory.php b/extensions/Wikibase/repo/includes/Validators/TermValidatorFactory.php index 3fa10c3..1cc80e7 100644 --- a/extensions/Wikibase/repo/includes/Validators/TermValidatorFactory.php +++ b/extensions/Wikibase/repo/includes/Validators/TermValidatorFactory.php @@ -128,7 +128,7 @@ $validators = array(); $validators[] = new TypeValidator( 'string' ); $validators[] = new StringLengthValidator( 1, $this->maxLength, 'mb_strlen' ); - $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/', true ); // no leading/trailing whitespace, no line breaks. + $validators[] = new RegexValidator( '/^\s|[\v\t]|\s$/u', true ); // no leading/trailing whitespace, no line breaks. return $validators; } diff --git a/extensions/Wikibase/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php b/extensions/Wikibase/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php index ae513b5..5214e38 100644 --- a/extensions/Wikibase/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php +++ b/extensions/Wikibase/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php @@ -111,6 +111,7 @@ return [ 'Space' => [ 'x x', true ], 'Unicode support' => [ 'Äöü', true ], + 'T161263' => [ 'Ӆ', true ], // Length checks 'To short' => [ '', false ], @@ -130,7 +131,7 @@ 'U+000B: Vertical tab' => [ "x\x0Bx", false ], 'U+000C: Form feed' => [ "x\fx", false ], 'U+000D: Return' => [ "x\rx", false ], - 'U+0085: Next line' => [ "x\x85x", false ], + 'U+0085: Next line' => [ "x\xC2\x85x", false ], ]; } diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index b0fc4ca..8bd93e0 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1628,12 +1628,12 @@ "source": { "type": "git", "url": "https://github.com/wikimedia/mediawiki-extensions-Wikibase.git", - "reference": "2755a3431f5a763b634c2c46d034ad34796631e0" + "reference": "0bca144964d2214aba02786e7eb4d384be926988" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/2755a3431f5a763b634c2c46d034ad34796631e0", - "reference": "2755a3431f5a763b634c2c46d034ad34796631e0", + "url": "https://api.github.com/repos/wikimedia/mediawiki-extensions-Wikibase/zipball/0bca144964d2214aba02786e7eb4d384be926988", + "reference": "0bca144964d2214aba02786e7eb4d384be926988", "shasum": "" }, "require": { @@ -1665,7 +1665,7 @@ "jakub-onderka/php-parallel-lint": ">=0.3 <0.10", "mediawiki/mediawiki-codesniffer": ">=0.4 <0.8" }, - "time": "2017-03-21 03:19:45", + "time": "2017-03-26 22:33:16", "type": "mediawiki-extension", "installation-source": "dist", "autoload": { -- To view, visit https://gerrit.wikimedia.org/r/344879 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ief7512b96cf4aa193314cec33920f28ad0dc9931 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/Wikidata Gerrit-Branch: wmf/1.29.0-wmf.17 Gerrit-Owner: Aude <aude.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits