From 8940af9d9bf5c9deb27840f0f7e76ff043ca2263 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 22 Dec 2016 17:20:33 +0100 Subject: [PATCH] Fixed handling of broken ACP controllers --- .../system/request/ControllerMap.class.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php index 068d03b930..ac436f1eec 100644 --- a/wcfsetup/install/files/lib/system/request/ControllerMap.class.php +++ b/wcfsetup/install/files/lib/system/request/ControllerMap.class.php @@ -363,7 +363,29 @@ class ControllerMap extends SingletonFactory { * @return string url representation, e.g. 'board-list' */ public static function transformController($controller) { - $parts = preg_split('~([A-Z][a-z0-9]+)~', $controller, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + // work-around for broken controllers that violate the strict naming rules + if (preg_match('~[A-Z]{2,}~', $controller)) { + $parts = preg_split('~([A-Z][a-z0-9]+)~', $controller, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + + // fix for invalid pages that would cause single character fragments + $sanitizedParts = []; + $tmp = ''; + foreach ($parts as $part) { + if (strlen($part) === 1) { + $tmp .= $part; + continue; + } + + $sanitizedParts[] = $tmp . $part; + $tmp = ''; + } + if ($tmp) $sanitizedParts[] = $tmp; + $parts = $sanitizedParts; + } + else { + $parts = preg_split('~([A-Z][a-z0-9]+)~', $controller, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); + } + $parts = array_map('strtolower', $parts); return implode('-', $parts); -- 2.20.1