Fixed handling of broken ACP controllers
authorAlexander Ebert <ebert@woltlab.com>
Thu, 22 Dec 2016 16:20:33 +0000 (17:20 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Thu, 22 Dec 2016 16:20:38 +0000 (17:20 +0100)
wcfsetup/install/files/lib/system/request/ControllerMap.class.php

index 068d03b930fd953bca0635fa3c695e57b1e66d77..ac436f1eec5b593bff5265fac7deb17e17091f6f 100644 (file)
@@ -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);