Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes

This commit is contained in:
Pantheon Automation 2016-04-20 09:56:34 -07:00 committed by Greg Anderson
parent b11a755ba8
commit c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions

View file

@ -39,32 +39,13 @@ class LengthValidator extends ConstraintValidator
}
$stringValue = (string) $value;
$invalidCharset = false;
if ('UTF8' === $charset = strtoupper($constraint->charset)) {
$charset = 'UTF-8';
$charset = 'UTF-8'; // iconv on Windows requires "UTF-8" instead of "UTF8"
}
if ('UTF-8' === $charset) {
if (!preg_match('//u', $stringValue)) {
$invalidCharset = true;
} elseif (function_exists('utf8_decode')) {
$length = strlen(utf8_decode($stringValue));
} else {
preg_replace('/./u', '', $stringValue, -1, $length);
}
} elseif (function_exists('mb_strlen')) {
if (@mb_check_encoding($stringValue, $constraint->charset)) {
$length = mb_strlen($stringValue, $constraint->charset);
} else {
$invalidCharset = true;
}
} elseif (function_exists('iconv_strlen')) {
$length = @iconv_strlen($stringValue, $constraint->charset);
$invalidCharset = false === $length;
} else {
$length = strlen($stringValue);
}
$length = @iconv_strlen($stringValue, $charset);
$invalidCharset = false === $length;
if ($invalidCharset) {
if ($this->context instanceof ExecutionContextInterface) {
@ -72,12 +53,14 @@ class LengthValidator extends ConstraintValidator
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ charset }}', $constraint->charset)
->setInvalidValue($value)
->setCode(Length::INVALID_CHARACTERS_ERROR)
->addViolation();
} else {
$this->buildViolation($constraint->charsetMessage)
->setParameter('{{ value }}', $this->formatValue($stringValue))
->setParameter('{{ charset }}', $constraint->charset)
->setInvalidValue($value)
->setCode(Length::INVALID_CHARACTERS_ERROR)
->addViolation();
}