From bd6fe703479bd9cae9f0d3e53f5a530c70da1017 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Wed, 8 Mar 2023 10:22:30 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#1699 --- wire/core/Sanitizer.php | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/wire/core/Sanitizer.php b/wire/core/Sanitizer.php index a7059a20..0c9b06bd 100644 --- a/wire/core/Sanitizer.php +++ b/wire/core/Sanitizer.php @@ -165,6 +165,14 @@ class Sanitizer extends Wire { */ protected $textTools = null; + /** + * Runtime caches + * + * @var array + * + */ + protected $caches = array(); + /** * UTF-8 whitespace hex codes * @@ -899,8 +907,15 @@ class Sanitizer extends Wire { // proceed only if value has some non-ascii characters if(ctype_alnum(str_replace($extras, '', $value))) { - // let regular pageName sanitizer handle this - return $this->pageName($value, false, $maxLength); + $k = 'pageNameUTF8.whitelistIsLowercase'; + if(!isset($this->caches[$k])) { + $this->caches[$k] = $whitelist !== false && $tt->strtolower($whitelist) === $whitelist; + } + if($this->caches[$k] || $tt->strtolower($value) === $value) { + // whitelist supports only lowercase OR value is all lowercase + // let regular pageName sanitizer handle this + return $this->pageName($value, false, $maxLength); + } } // validate that all characters are in our whitelist