From 754bcf034cdc5c7ab8f2ed85b1f352d8e5eda162 Mon Sep 17 00:00:00 2001 From: Kim Peeters Date: Wed, 29 Jul 2015 14:42:28 +0200 Subject: [PATCH 1/2] Allow sanitation of value without maximum length --- wire/core/Sanitizer.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php index 0722cec5..de241007 100644 --- a/wire/core/Sanitizer.php +++ b/wire/core/Sanitizer.php @@ -55,7 +55,7 @@ public function __construct() { * @param array $allowedExtras Additional characters that are allowed in the value * @param string 1 character replacement value for invalid characters * @param bool $beautify Whether to beautify the string, specify Sanitizer::translate to perform transliteration. - * @param int $maxLength + * @param mixed $maxLength Maximum length for input, false for no limit * @return string * */ @@ -90,7 +90,7 @@ public function nameFilter($value, array $allowedExtras, $replacementChar, $beau $needsWork = strlen(str_replace($allowed, '', $value)); } - if(strlen($value) > $maxLength) $value = substr($value, 0, $maxLength); + if((ctype_digit($maxLength) || is_int($maxLength)) && strlen($value) > $maxLength) $value = substr($value, 0, $maxLength); if($needsWork) { $value = str_replace(array("'", '"'), '', $value); // blank out any quotes From 7e85b3488c5f472dee9ca6329125e034ac3fbdf1 Mon Sep 17 00:00:00 2001 From: Kim Peeters Date: Wed, 29 Jul 2015 14:44:01 +0200 Subject: [PATCH 2/2] Don't break url segments with over 128 characters --- wire/core/WireInput.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wire/core/WireInput.php b/wire/core/WireInput.php index e36c9db2..b6626cb8 100644 --- a/wire/core/WireInput.php +++ b/wire/core/WireInput.php @@ -259,7 +259,7 @@ public function setUrlSegment($num, $value) { $this->urlSegments = $urlSegments; } else { // set - $this->urlSegments[$num] = wire('sanitizer')->name($value); + $this->urlSegments[$num] = wire('sanitizer')->name($value,false,false); } }