From 882212520ffaafbde936b40c37eed85ef2cf151c Mon Sep 17 00:00:00 2001 From: Matias Griese Date: Wed, 17 Apr 2019 16:24:03 +0300 Subject: [PATCH] Fixed bug in text field filtering: return empty string if value isn't a string or number --- CHANGELOG.md | 4 +++- system/src/Grav/Common/Data/Validation.php | 4 ++++ .../src/Grav/Framework/Object/Access/NestedPropertyTrait.php | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 245955fba..b19cf75cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,9 @@ 1. [](#new) * `FormInterface` now implements `RenderInterface` * Added new `FormInterface::getTask()` method which reads the task from `form.task` in the blueprint - +1. [](#bugfix) + * 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];