diff --git a/CHANGELOG.md b/CHANGELOG.md index 697585e51..8542d1f19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ * Added new `FormInterface::getTask()` method which reads the task from `form.task` in the blueprint 1. [](#bugfix) * Rollback `redirect_default_route` logic as it has issues with multilang [#2459](https://github.com/getgrav/grav/issues/2459) + * Fixed bug in text field filtering: return empty string if value isn't a string or number # v1.6.5 ## 04/15/2019 diff --git a/system/src/Grav/Common/Data/Validation.php b/system/src/Grav/Common/Data/Validation.php index 969ad8135..8ff199bd9 100644 --- a/system/src/Grav/Common/Data/Validation.php +++ b/system/src/Grav/Common/Data/Validation.php @@ -154,6 +154,10 @@ class Validation protected static function filterText($value, array $params, array $field) { + if (!\is_string($value) && !is_numeric($value)) { + return ''; + } + if (!empty($params['trim'])) { $value = trim($value); } diff --git a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php index 1896f47a5..22008714b 100644 --- a/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php +++ b/system/src/Grav/Framework/Object/Access/NestedPropertyTrait.php @@ -103,7 +103,7 @@ trait NestedPropertyTrait $current[$offset] = []; } } else { - throw new \RuntimeException('Cannot set nested property on non-array value'); + throw new \RuntimeException("Cannot set nested property {$property} on non-array value"); } $current = &$current[$offset]; @@ -147,7 +147,7 @@ trait NestedPropertyTrait return $this; } } else { - throw new \RuntimeException('Cannot set nested property on non-array value'); + throw new \RuntimeException("Cannot unset nested property {$property} on non-array value"); } $current = &$current[$offset];