Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TASK] Redirect non-safe URLs the the safe notation #618

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions Classes/Decoder/UrlDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -1516,21 +1516,39 @@ protected function searchPathInCache(array &$pathSegments) {
});
$path = implode('/', $pathSegmentsCopy);

// Since we know nothing about mount point at this stage, we exclude it from search by passing null as the second argument
$cacheEntry = $this->cache->getPathFromCacheByPagePath($this->rootPageId, $this->detectedLanguageId, null, $path);
if ($cacheEntry) {
if ((int)$cacheEntry->getExpiration() !== 0) {
$this->isExpiredPath = TRUE;
$nonExpiredCacheEntry = $this->cache->getPathFromCacheByPageId($cacheEntry->getRootPageId(), $cacheEntry->getLanguageId(), $cacheEntry->getPageId(), $cacheEntry->getMountPoint());
if ($nonExpiredCacheEntry) {
$this->expiredPath = $cacheEntry->getPagePath();
$cacheEntry = $nonExpiredCacheEntry;
}
}
// Check if the safe-string path contains changes
if ($pathSegmentsCopy !== $pathSegments) {
/** @var \DmitryDulepov\Realurl\Cache\PathCacheEntry $cacheEntry */
$cacheEntry = GeneralUtility::makeInstance('DmitryDulepov\\Realurl\\Cache\\PathCacheEntry');
$cacheEntry->setPagePath($path);

// Generate the original path and mark it as expired
array_walk($pathSegments, function(&$segment) {
$segment = rawurlencode($segment);
});
$expiredPath = implode('/', $pathSegments);

$this->isExpiredPath = TRUE;
$this->expiredPath = $expiredPath;
$result = $cacheEntry;
} else {
if (count($pathSegments) > 0) {
array_unshift($removedSegments, array_pop($pathSegments));

// Since we know nothing about mount point at this stage, we exclude it from search by passing null as the second argument
$cacheEntry = $this->cache->getPathFromCacheByPagePath($this->rootPageId, $this->detectedLanguageId, null, $path);
if ($cacheEntry) {
if ((int)$cacheEntry->getExpiration() !== 0) {
$this->isExpiredPath = TRUE;
$nonExpiredCacheEntry = $this->cache->getPathFromCacheByPageId($cacheEntry->getRootPageId(), $cacheEntry->getLanguageId(), $cacheEntry->getPageId(), $cacheEntry->getMountPoint());
if ($nonExpiredCacheEntry) {
$this->expiredPath = $cacheEntry->getPagePath();
$cacheEntry = $nonExpiredCacheEntry;
}
}
$result = $cacheEntry;
} else {
if (count($pathSegments) > 0) {
array_unshift($removedSegments, array_pop($pathSegments));
}
}
}
} while (is_null($result) && count($pathSegments) > 0);
Expand Down