[TASK] Skip GeneralUtility::resolveBackPath() if its not necessary 97/27197/3
authorAndreas Wolf <andreas.wolf@typo3.org>
Fri, 31 Jan 2014 14:33:11 +0000 (15:33 +0100)
committerChristian Kuhn <lolli@schwarzbu.ch>
Fri, 31 Jan 2014 16:43:04 +0000 (17:43 +0100)
resolveBackPath() is run a couple hundred times per script run,
especially in the backend. As this method is only really necessary in a
few special cases (when a path really contains "../"), we can skip it
for all other paths with an early return.

The check is really weak (it will not skip the call for things like
"/some/dir..with..dots..inbetween/"), but this is ok because we just use
it to skip all *really* obvious cases while at best not missing *any*
legitimate use-case, which should be achieved with this commit.

Change-Id: I4e7fbd2076323e682fcf66bc57605f817cd3e03c
Resolves: #55519
Releases: 6.2
Reviewed-on: https://review.typo3.org/27197
Reviewed-by: Jan Helke
Tested-by: Jan Helke
Reviewed-by: Christian Kuhn
Tested-by: Christian Kuhn
typo3/sysext/core/Classes/Utility/GeneralUtility.php

index fec132f..cc3aeb9 100644 (file)
@@ -2973,6 +2973,9 @@ Connection: close
         * @return string
         */
        static public function resolveBackPath($pathStr) {
+               if (strpos($pathStr, '..') === FALSE) {
+                       return $pathStr;
+               }
                $parts = explode('/', $pathStr);
                $output = array();
                $c = 0;