Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 0 additions & 32 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,13 @@ branches:
cache:
directories:
- $HOME/.composer/cache
- $HOME/.local
- zf-mkdoc-theme

env:
global:
- COMPOSER_ARGS="--no-interaction"
- COVERAGE_DEPS="satooshi/php-coveralls"
- LEGACY_DEPS="phpunit/phpunit"
- TESTS_ZEND_VALIDATOR_ONLINE_ENABLED=true
- SITE_URL=https://zendframework.github.io/zend-validator
- GH_USER_NAME="Matthew Weier O'Phinney"
- GH_USER_EMAIL=matthew@weierophinney.net
- GH_REF=github.com/zendframework/zend-validator.git
- secure="SoUsUxBFCuC0rVQyDJ/+IB38glC5WeWvg0XxtNj79di7wsQ92Jofp6Uu3NJBB8H1+at1pHetphRm4N+GPQmZGMFTG7LyF5u8duV8t4nDpAz5WfoP1y0IyacP6IrWzANeszOTZ04dlHu3dBdHusNpNxxUHl97bSx4XQUAm2GUTqNkuXNgQJFAAxx91jb5txG4W8KeMnfRm9jeDHP17BCnBMaSkYEXeLpHkYa9wA4lBJ7ZD6LuSC+MhrJCtREBTsWKLJY6xeBjRorUug+uCrNyArPtcOAaOLMSDJ1XIi3L5/Q7HdoldV7aC3V5HjNlpdIEFl33IGiCOyictFCpT1KaKx7TL8zDTMCiqe0cCyfTnq28lzULz2hXg0Kov7BFcRr2Ht/1f96RgrakWQiYTmk+C3YYYA16Fb+MndkMI3WH7WI0suC+5nhPdGl53MCWsd5x2+dDk/ifB/VvxHdGhhgxzAxsYJ41gV/LlzjbCQJNDCnTaL/GHCTUGJEPgwLrn2W52uZx6VggE9wl5z4XkiPqBy6zAAdwF55RRJgCxFttGOMVGdegFLHTf6+13S4sEImNmyVTeuJBZEHxaYRJ21wweOocjC2StKC9V54uPysDcEYwhu8WOsYU34fQdpMx3OHfPmXvhNGqoZ1rVsd5HM0QZZMT+7SI0r3UNKxrPC8LEAU="

matrix:
include:
Expand All @@ -35,12 +28,6 @@ matrix:
- DEPS=locked
- EXECUTE_HOSTNAME_CHECK=true
- TEST_COVERAGE=true
- DEPLOY_DOCS="$(if [[ $TRAVIS_BRANCH == 'master' && $TRAVIS_PULL_REQUEST == 'false' ]]; then echo -n 'true' ; else echo -n 'false' ; fi)"
- PATH="$HOME/.local/bin:$PATH"
- php: 5.6
env:
- DEPS=locked
- SERVICE_MANAGER_VERSION="^2.7.5"
- php: 5.6
env:
- DEPS=latest
Expand All @@ -51,10 +38,6 @@ matrix:
env:
- DEPS=locked
- CS_CHECK=true
- php: 7
env:
- DEPS=locked
- SERVICE_MANAGER_VERSION="^2.7.5"
- php: 7
env:
- DEPS=latest
Expand All @@ -76,10 +59,6 @@ matrix:
- php: hhvm
env:
- DEPS=latest
- php: hhvm
env:
- DEPS=locked
- SERVICE_MANAGER_VERSION="^2.7.5"
allow_failures:
- php: hhvm

Expand All @@ -92,8 +71,6 @@ install:
- if [[ $TRAVIS_PHP_VERSION =~ ^5.6 ]]; then travis_retry composer update $COMPOSER_ARGS --with-dependencies $LEGACY_DEPS ; fi
- if [[ $DEPS == 'latest' ]]; then travis_retry composer update $COMPOSER_ARGS ; fi
- if [[ $DEPS == 'lowest' ]]; then travis_retry composer update --prefer-lowest --prefer-stable $COMPOSER_ARGS ; fi
- if [[ $SERVICE_MANAGER_VERSION != '' ]]; then travis_retry composer require --dev --no-update $COMPOSER_ARGS "zendframework/zend-servicemanager:$SERVICE_MANAGER_VERSION" ; fi
- if [[ $SERVICE_MANAGER_VERSION == '' ]]; then travis_retry composer require --dev --no-update $COMPOSER_ARGS "zendframework/zend-servicemanager:^3.0.3" ; fi
- if [[ $TEST_COVERAGE == 'true' ]]; then travis_retry composer require --dev $COMPOSER_ARGS $COVERAGE_DEPS ; fi
- stty cols 120
- COLUMNS=120 composer show
Expand All @@ -102,18 +79,9 @@ script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer test-coverage ; else composer test ; fi
- if [[ $CS_CHECK == 'true' ]]; then composer cs-check ; fi
- if [[ $EXECUTE_HOSTNAME_CHECK == "true" && $TRAVIS_PULL_REQUEST == "false" ]]; then php bin/update_hostname_validator.php --check-only; fi
- if [[ $DEPLOY_DOCS == "true" && "$TRAVIS_TEST_RESULT" == "0" ]]; then wget -O theme-installer.sh "https://raw.githubusercontent.com/zendframework/zf-mkdoc-theme/master/theme-installer.sh" ; chmod 755 theme-installer.sh ; ./theme-installer.sh ; fi

after_script:
- if [[ $TEST_COVERAGE == 'true' ]]; then composer upload-coverage ; fi

after_success:
- if [[ $DEPLOY_DOCS == "true" ]]; then echo "Preparing to build and deploy documentation" ; ./zf-mkdoc-theme/deploy.sh ; echo "Completed deploying documentation" ; fi

notifications:
email: false
slack:
rooms:
- secure: "ujQTv4jUDjnWAUME3w2VoPyKPBwbCGa7b1YMKxOt4PWxjWuyIUDY743fnmcQUqkX+CUXz9qJHG124RyZQ6UUowG/NZDttp7lppU/bIGJ/K0MuVmpBVwb8y/6rDoRj37V4n8WqAHGevjlRet3E5+gl91PFuSpN5JSj4efI8MlgUF6mqIIZUOifq2yNTZ9MXrG2qojIN4o6G4gttfwUR/3Ah1nD/ZtQBLA7pTd31/UNwtZMQ4IbGmcCMpdUADbQDr24VubjzTJfweSBoAu8Xf3IPPdR5AEfdRvuT1tGYPP4YxmvHxpTH1wF3mCX6b6ubUFMlpbqE50y/v4Mlva+2jXvcZ9Lt/Fs1Hz4pR3P3mM8EJjtj55cXWm+MSBqPBN7SX6AnkYB/OznuzqbCvt5Te09fm++1REYGnxkLxCnwI9GN2sKS7Tr8NxUCZyi9d4sVh7KUnrwFGVAGpViBTeglq+epoClcwupLK1E2m8IjrjUHTYG6NCE1QF/1NrrwuFBUIQuxPj/uE4oZcb8Tmiz9ilGFw/JbMR6WKzYzDSk2GrkJjUpa8Pn570kDL3otfJImPnEOxN73m9jle6P3laVJP9/A5Vm9C86S0aghAaswxCZB7Fql0Pl01WAB1kufqQBM/euFWGB0bQ9TFWoOENZDfD9zGyTkeZq3mgZ6DgU7ft6FA="
on_success: change
on_failure: always
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#180](https://github.com/zendframework/zend-validator/pull/180) fixes how
`Zend\Validator\File\MimeType` "closes" the open FileInfo handle for the file
being validated, using `unset()` instead of `finfo_close()`; this resolves a
segfault that occurs on older PHP versions.
- [#174](https://github.com/zendframework/zend-validator/pull/174) fixes how
`Zend\Validator\Between` handles two situations: (1) when a non-numeric value
is validated against numeric min/max values, and (2) when a numeric value is
validated against non-numeric min/max values. Previously, these incorrectly
validated as true; now they are marked invalid.

## 2.9.1 - 2017-05-17

Expand Down
2 changes: 1 addition & 1 deletion doc/book/validators/date.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ $validator->isValid('10.10.2000'); // returns false

`Zend\Validator\Date` also supports custom date formats. When you want to
validate such a date, use the `format` option. This option accepts any format
allowed by the PHP [date()](http://php.net/date) function.
allowed by the PHP [DateTime::createFromFormat()](http://php.net/manual/en/datetime.createfromformat.php#refsect1-datetime.createfromformat-parameters) method.

```php
$validator = new Zend\Validator\Date(['format' => 'Y']);
Expand Down
35 changes: 33 additions & 2 deletions src/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ class Between extends AbstractValidator
{
const NOT_BETWEEN = 'notBetween';
const NOT_BETWEEN_STRICT = 'notBetweenStrict';
const VALUE_NOT_NUMERIC = 'valueNotNumeric';
const VALUE_NOT_STRING = 'valueNotString';

/**
* Retain if min and max are numeric values. Allow to not compare string and numeric types
*
* @var boolean
*/
private $numeric;

/**
* Validation failure message template definitions
Expand All @@ -24,7 +33,10 @@ class Between extends AbstractValidator
*/
protected $messageTemplates = [
self::NOT_BETWEEN => "The input is not between '%min%' and '%max%', inclusively",
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'"
self::NOT_BETWEEN_STRICT => "The input is not strictly between '%min%' and '%max%'",
self::VALUE_NOT_NUMERIC => "The min ('%min%') and max ('%max%') values are numeric, but the input is not",
self::VALUE_NOT_STRING => "The min ('%min%') and max ('%max%') values are non-numeric strings, "
. "but the input is not a string",
];

/**
Expand Down Expand Up @@ -81,7 +93,17 @@ public function __construct($options = null)
if (count($options) !== 2
&& (! array_key_exists('min', $options) || ! array_key_exists('max', $options))
) {
throw new Exception\InvalidArgumentException("Missing option. 'min' and 'max' have to be given");
throw new Exception\InvalidArgumentException("Missing option: 'min' and 'max' have to be given");
}

if (is_numeric($options['min']) && is_numeric($options['max'])) {
$this->numeric = true;
} elseif (is_string($options['min']) && is_string($options['max'])) {
$this->numeric = false;
} else {
throw new Exception\InvalidArgumentException(
"Invalid options: 'min' and 'max' should be of the same scalar type"
);
}

parent::__construct($options);
Expand Down Expand Up @@ -164,6 +186,15 @@ public function isValid($value)
{
$this->setValue($value);

if ($this->numeric && ! is_numeric($value)) {
$this->error(self::VALUE_NOT_NUMERIC);
return false;
}
if (! $this->numeric && ! is_string($value)) {
$this->error(self::VALUE_NOT_STRING);
return false;
}

if ($this->getInclusive()) {
if ($this->getMin() > $value || $value > $this->getMax()) {
$this->error(self::NOT_BETWEEN);
Expand Down
2 changes: 1 addition & 1 deletion src/File/MimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ public function isValid($value, $file = null)
$this->type = null;
if (! empty($this->finfo)) {
$this->type = finfo_file($this->finfo, $file);
finfo_close($this->finfo);
unset($this->finfo);
}
}

Expand Down
19 changes: 18 additions & 1 deletion src/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Hostname extends AbstractValidator

/**
* Array of valid top-level-domains
* IanaVersion 2017051700
* IanaVersion 2017071801
*
* @see ftp://data.iana.org/TLD/tlds-alpha-by-domain.txt List of all TLDs by domain
* @see http://www.iana.org/domains/root/db/ Official list of supported TLDs
Expand Down Expand Up @@ -144,6 +144,7 @@ class Hostname extends AbstractValidator
'aq',
'aquarelle',
'ar',
'arab',
'aramco',
'archi',
'army',
Expand Down Expand Up @@ -479,6 +480,7 @@ class Hostname extends AbstractValidator
'estate',
'esurance',
'et',
'etisalat',
'eu',
'eurovision',
'eus',
Expand Down Expand Up @@ -613,6 +615,7 @@ class Hostname extends AbstractValidator
'gratis',
'green',
'gripe',
'grocery',
'group',
'gs',
'gt',
Expand Down Expand Up @@ -853,6 +856,7 @@ class Hostname extends AbstractValidator
'man',
'management',
'mango',
'map',
'market',
'marketing',
'markets',
Expand All @@ -876,6 +880,7 @@ class Hostname extends AbstractValidator
'men',
'menu',
'meo',
'merckmsd',
'metlife',
'mg',
'mh',
Expand Down Expand Up @@ -1028,6 +1033,7 @@ class Hostname extends AbstractValidator
'pg',
'ph',
'pharmacy',
'phd',
'philips',
'phone',
'photo',
Expand Down Expand Up @@ -1173,6 +1179,7 @@ class Hostname extends AbstractValidator
'scot',
'sd',
'se',
'search',
'seat',
'secure',
'security',
Expand Down Expand Up @@ -1444,13 +1451,16 @@ class Hostname extends AbstractValidator
'कॉम',
'セール',
'佛山',
'ಭಾರತ',
'慈善',
'集团',
'在线',
'한국',
'ଭାରତ',
'大众汽车',
'点看',
'คอม',
'ভাৰত',
'ভারত',
'八卦',
'موقع',
Expand Down Expand Up @@ -1504,7 +1514,9 @@ class Hostname extends AbstractValidator
'クラウド',
'ભારત',
'通販',
'भारतम्',
'भारत',
'भारोत',
'网店',
'संगठन',
'餐厅',
Expand All @@ -1525,15 +1537,18 @@ class Hostname extends AbstractValidator
'ارامكو',
'ایران',
'العليان',
'اتصالات',
'امارات',
'بازار',
'پاکستان',
'الاردن',
'موبايلي',
'بارت',
'بھارت',
'المغرب',
'ابوظبي',
'السعودية',
'ڀارت',
'كاثوليك',
'سودان',
'همراه',
Expand All @@ -1544,6 +1559,7 @@ class Hostname extends AbstractValidator
'政府',
'شبكة',
'بيتك',
'عرب',
'გე',
'机构',
'组织机构',
Expand All @@ -1560,6 +1576,7 @@ class Hostname extends AbstractValidator
'ελ',
'世界',
'書籍',
'ഭാരതം',
'ਭਾਰਤ',
'网址',
'닷넷',
Expand Down
Loading