From 6dbb244654290bfe68bad407257e0eba5f87b1f0 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Thu, 8 Feb 2018 08:51:33 -0500 Subject: [PATCH] Fix issue processwire/processwire-issues#488 where UTF-8 mode urlSegments that contained only ascii would get converted to lowercase --- wire/core/WireInput.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/wire/core/WireInput.php b/wire/core/WireInput.php index c397688f..a5bb993a 100644 --- a/wire/core/WireInput.php +++ b/wire/core/WireInput.php @@ -289,12 +289,14 @@ class WireInput extends Wire { $urlSegments[++$n] = $v; } $this->urlSegments = $urlSegments; - } else if($this->wire('config')->pageNameCharset == 'UTF8') { - // set UTF8 - $this->urlSegments[$num] = $this->wire('sanitizer')->pageNameUTF8($value, $maxLength); } else { - // set ascii - $this->urlSegments[$num] = $this->wire('sanitizer')->name($value, false, $maxLength); + // sanitize to standard PW name format + $urlSegment = $this->wire('sanitizer')->name($value, false, $maxLength); + // if UTF-8 mode and value changed during name sanitization, try pageNameUTF8 instead + if($urlSegment !== $value && $this->wire('config')->pageNameCharset == 'UTF8') { + $urlSegment = $this->wire('sanitizer')->pageNameUTF8($value, $maxLength); + } + $this->urlSegments[$num] = $urlSegment; } }