[BUGFIX] PublicURL calculation for storage 0 is wrong 95/28395/7
authorSteffen Ritter <info@rs-websystems.de>
Fri, 14 Mar 2014 18:04:13 +0000 (19:04 +0100)
committerXavier Perseguers <xavier@typo3.org>
Sat, 15 Mar 2014 10:17:56 +0000 (11:17 +0100)
Since the refactoring of the publicURL Feature and the possibility to
link to files via jump-scripts the generation of publicUrls for files
in storage zero is broken due to the fact that every relative base-path
for this URL is appended with a slash.

If the base-path has been empty (like for storage 0), appending a slash
makes it absolute.

This patch changes the behaviour to only append a slash on non-empty
paths.

Releases: 6.2
Resolves: #56927
Change-Id: I14e8bae0b64ed8dc537a5edbf57d9dce6ddf0932
Reviewed-on: https://review.typo3.org/28395
Reviewed-by: Alexander Stehlik
Tested-by: Alexander Stehlik
Reviewed-by: Xavier Perseguers
Tested-by: Xavier Perseguers
typo3/sysext/core/Classes/Resource/Driver/LocalDriver.php

index 4197c56..e6a3955 100644 (file)
@@ -139,10 +139,13 @@ class LocalDriver extends AbstractHierarchicalFilesystemDriver {
                if ($this->hasCapability(\TYPO3\CMS\Core\Resource\ResourceStorage::CAPABILITY_PUBLIC)) {
                        if (GeneralUtility::isFirstPartOfStr($this->absoluteBasePath, PATH_site)) {
                                // use site-relative URLs
-                               $temporaryBaseUri = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->absoluteBasePath);
-                               $uriParts = explode('/', rtrim($temporaryBaseUri, '/'));
-                               array_map('rawurlencode', $uriParts);
-                               $this->baseUri = implode('/', $uriParts) . '/';
+                               $temporaryBaseUri = rtrim(\TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($this->absoluteBasePath), '/');
+                               if ($temporaryBaseUri !== '') {
+                                       $uriParts = explode('/', $temporaryBaseUri);
+                                       array_map('rawurlencode', $uriParts);
+                                       $temporaryBaseUri = implode('/', $uriParts) . '/';
+                               }
+                               $this->baseUri = $temporaryBaseUri;
                        } elseif (isset($this->configuration['baseUri']) && GeneralUtility::isValidUrl($this->configuration['baseUri'])) {
                                $this->baseUri = rtrim($this->configuration['baseUri'], '/') . '/';
                        }