[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Change bad ASCII to UTF-8 validation in terms/value validators

2017-03-24 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/344597 )

Change subject: Change bad ASCII to UTF-8 validation in terms/value validators
..


Change bad ASCII to UTF-8 validation in terms/value validators

We need to BACKPORT this. Not necesarrily the tests. I also believe the
changes to ValidatorBuilders are not deployed yet. So the only file that
needs backporting is TermValidatorFactory.

Bug: T161263
Change-Id: If129df5364afd03848d40658f605923d252e4a69
---
M repo/includes/ValidatorBuilders.php
M repo/includes/Validators/TermValidatorFactory.php
M repo/tests/phpunit/includes/ValidatorBuildersTest.php
M repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
4 files changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Daniel Kinzler: Looks good to me, approved
  Aleksey Bekh-Ivanov (WMDE): Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/ValidatorBuilders.php 
b/repo/includes/ValidatorBuilders.php
index af5649d..f11a072 100644
--- a/repo/includes/ValidatorBuilders.php
+++ b/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|[\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/repo/includes/Validators/TermValidatorFactory.php 
b/repo/includes/Validators/TermValidatorFactory.php
index 3fa10c3..1cc80e7 100644
--- a/repo/includes/Validators/TermValidatorFactory.php
+++ b/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/repo/tests/phpunit/includes/ValidatorBuildersTest.php 
b/repo/tests/phpunit/includes/ValidatorBuildersTest.php
index c142225..31d8f8d 100644
--- a/repo/tests/phpunit/includes/ValidatorBuildersTest.php
+++ b/repo/tests/phpunit/includes/ValidatorBuildersTest.php
@@ -221,6 +221,7 @@
return [
'Space' => [ 'x x', true ],
'Unicode support' => [ 'Äöü', true ],
+   'T161263' => [ 'Ӆ', true ],
 
// Length checks
'To short' => [ '', false ],
@@ -240,7 +241,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/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php 
b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
index ae513b5..5214e38 100644
--- a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
+++ b/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 ],
];
}
 

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If129df5364afd03848d40658f605923d252e4a69
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) 
Gerrit-Reviewer: Addshore 
Gerrit-Reviewer: Aleksey Bekh-Ivanov (WMDE) 

[MediaWiki-commits] [Gerrit] mediawiki...Wikibase[master]: Change bad ASCII to UTF-8 validation in terms/value validators

2017-03-24 Thread WMDE
Thiemo Mättig (WMDE) has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/344597 )

Change subject: Change bad ASCII to UTF-8 validation in terms/value validators
..

Change bad ASCII to UTF-8 validation in terms/value validators

We need to BACKPORT this. Not necesarrily the tests. I also believe the
changes to ValidatorBuilders are not deployed yet. So the only file that
needs backporting is TermValidatorFactory.

Bug: T161263
Change-Id: If129df5364afd03848d40658f605923d252e4a69
---
M repo/includes/ValidatorBuilders.php
M repo/includes/Validators/TermValidatorFactory.php
M repo/tests/phpunit/includes/ValidatorBuildersTest.php
M repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
4 files changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/97/344597/1

diff --git a/repo/includes/ValidatorBuilders.php 
b/repo/includes/ValidatorBuilders.php
index af5649d..f11a072 100644
--- a/repo/includes/ValidatorBuilders.php
+++ b/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|[\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/repo/includes/Validators/TermValidatorFactory.php 
b/repo/includes/Validators/TermValidatorFactory.php
index 3fa10c3..1cc80e7 100644
--- a/repo/includes/Validators/TermValidatorFactory.php
+++ b/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/repo/tests/phpunit/includes/ValidatorBuildersTest.php 
b/repo/tests/phpunit/includes/ValidatorBuildersTest.php
index c142225..31d8f8d 100644
--- a/repo/tests/phpunit/includes/ValidatorBuildersTest.php
+++ b/repo/tests/phpunit/includes/ValidatorBuildersTest.php
@@ -221,6 +221,7 @@
return [
'Space' => [ 'x x', true ],
'Unicode support' => [ 'Äöü', true ],
+   'T161263' => [ 'Ӆ', true ],
 
// Length checks
'To short' => [ '', false ],
@@ -240,7 +241,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/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php 
b/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
index ae513b5..5214e38 100644
--- a/repo/tests/phpunit/includes/Validators/TermValidatorFactoryTest.php
+++ b/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 ],
];
}
 

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If129df5364afd03848d40658f605923d252e4a69
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Thiemo Mättig (WMDE) 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org