From 6b0282e5bb27aa6570507df8f22e7587a7f622b3 Mon Sep 17 00:00:00 2001 From: Benjamin Mack <benni@typo3.org> Date: Wed, 28 Oct 2015 23:49:16 +0100 Subject: [PATCH] [!!!][TASK] Remove EXT:jumpurl from the core The JumpURL generation and handling which was put into its own extension is now removed from the core. It is now maintained on GitHub: https://github.com/FriendsOfTYPO3/jumpurl Resolves: #70578 Releases: master Change-Id: Icf8436967d0d575c3d2199f46eb39fb76a8b366e Reviewed-on: https://review.typo3.org/44341 Reviewed-by: Wouter Wolters <typo3@wouterwolters.nl> Tested-by: Wouter Wolters <typo3@wouterwolters.nl> Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de> Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de> --- composer.json | 2 - composer.lock | 2 +- ...RLFunctionalityRemovedFromTheTYPO3Core.rst | 29 ++ .../sysext/jumpurl/Classes/JumpUrlHandler.php | 346 --------------- .../jumpurl/Classes/JumpUrlProcessor.php | 211 --------- .../sysext/jumpurl/Classes/JumpUrlUtility.php | 48 --- typo3/sysext/jumpurl/Documentation/.gitignore | 7 - .../Documentation/Configuration/Index.rst | 208 --------- .../sysext/jumpurl/Documentation/Includes.txt | 21 - typo3/sysext/jumpurl/Documentation/Index.rst | 60 --- .../Documentation/Introduction/Index.rst | 57 --- .../sysext/jumpurl/Documentation/Settings.yml | 15 - .../sysext/jumpurl/Documentation/Targets.rst | 13 - .../Tests/Unit/ContentObjectRendererTest.php | 401 ------------------ .../jumpurl/Tests/Unit/JumpUrlHandlerTest.php | 358 ---------------- .../Tests/Unit/JumpUrlProcessorMock.php | 35 -- .../Tests/Unit/JumpUrlProcessorTest.php | 101 ----- typo3/sysext/jumpurl/composer.json | 25 -- typo3/sysext/jumpurl/ext_emconf.php | 21 - typo3/sysext/jumpurl/ext_icon.png | Bin 3450 -> 0 bytes typo3/sysext/jumpurl/ext_localconf.php | 11 - 21 files changed, 30 insertions(+), 1941 deletions(-) create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Breaking-70578-JumpURLFunctionalityRemovedFromTheTYPO3Core.rst delete mode 100644 typo3/sysext/jumpurl/Classes/JumpUrlHandler.php delete mode 100644 typo3/sysext/jumpurl/Classes/JumpUrlProcessor.php delete mode 100644 typo3/sysext/jumpurl/Classes/JumpUrlUtility.php delete mode 100644 typo3/sysext/jumpurl/Documentation/.gitignore delete mode 100644 typo3/sysext/jumpurl/Documentation/Configuration/Index.rst delete mode 100644 typo3/sysext/jumpurl/Documentation/Includes.txt delete mode 100644 typo3/sysext/jumpurl/Documentation/Index.rst delete mode 100644 typo3/sysext/jumpurl/Documentation/Introduction/Index.rst delete mode 100644 typo3/sysext/jumpurl/Documentation/Settings.yml delete mode 100644 typo3/sysext/jumpurl/Documentation/Targets.rst delete mode 100644 typo3/sysext/jumpurl/Tests/Unit/ContentObjectRendererTest.php delete mode 100644 typo3/sysext/jumpurl/Tests/Unit/JumpUrlHandlerTest.php delete mode 100644 typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorMock.php delete mode 100644 typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorTest.php delete mode 100644 typo3/sysext/jumpurl/composer.json delete mode 100644 typo3/sysext/jumpurl/ext_emconf.php delete mode 100644 typo3/sysext/jumpurl/ext_icon.png delete mode 100644 typo3/sysext/jumpurl/ext_localconf.php diff --git a/composer.json b/composer.json index fef28b10dc5a..3f30a15a52c8 100644 --- a/composer.json +++ b/composer.json @@ -200,8 +200,6 @@ "TYPO3\\CMS\\Impexp\\Tests\\": "typo3/sysext/impexp/Tests/", "TYPO3\\CMS\\IndexedSearch\\Tests\\": "typo3/sysext/indexed_search/Tests/", "TYPO3\\CMS\\Install\\Tests\\": "typo3/sysext/install/Tests/", - "FoT3\\Jumpurl\\": "typo3/sysext/jumpurl/Classes/", - "FoT3\\Jumpurl\\Tests\\": "typo3/sysext/jumpurl/Tests/", "TYPO3\\CMS\\Lang\\Tests\\": "typo3/sysext/lang/Tests/", "TYPO3\\CMS\\Lowlevel\\Tests\\": "typo3/sysext/lowlevel/Tests/", "TYPO3\\CMS\\Recordlist\\Tests\\": "typo3/sysext/recordlist/Tests/", diff --git a/composer.lock b/composer.lock index 60f77aa0a6e1..56710a5652f0 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "86c884e10a0b730855e327edfd19fd02", + "hash": "bca7240d8b2c86b9165c3efef17ffeb5", "content-hash": "2988051bfeacaa2d95da8d796d9c5bd8", "packages": [ { diff --git a/typo3/sysext/core/Documentation/Changelog/master/Breaking-70578-JumpURLFunctionalityRemovedFromTheTYPO3Core.rst b/typo3/sysext/core/Documentation/Changelog/master/Breaking-70578-JumpURLFunctionalityRemovedFromTheTYPO3Core.rst new file mode 100644 index 000000000000..2ef3ec716d27 --- /dev/null +++ b/typo3/sysext/core/Documentation/Changelog/master/Breaking-70578-JumpURLFunctionalityRemovedFromTheTYPO3Core.rst @@ -0,0 +1,29 @@ +==================================================================== +Breaking: #70578 - JumpURL functionality removed from the TYPO3 Core +==================================================================== + +Description +=========== + +The handling and generation of so-called Jump URLs has been moved into its own extension called "jumpurl" +and is now available in the TYPO3 Extension Repository (TER), and available via composer as the package name +"friendsoftypo3/jumpurl". + + +Impact +====== + +If the functionality was used in an installation before (e.g. with Direct Mail or via TypoScript), this functionality is +not working anymore. + + +Affected Installations +====================== + +All installations where Jump URLs were used. + + +Migration +========= + +Download and install the extension "jumpurl" from the TER. \ No newline at end of file diff --git a/typo3/sysext/jumpurl/Classes/JumpUrlHandler.php b/typo3/sysext/jumpurl/Classes/JumpUrlHandler.php deleted file mode 100644 index e3a78c97c69c..000000000000 --- a/typo3/sysext/jumpurl/Classes/JumpUrlHandler.php +++ /dev/null @@ -1,346 +0,0 @@ -<?php -namespace FoT3\Jumpurl; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Core\Resource\FileInterface; -use TYPO3\CMS\Core\Resource\ResourceFactory; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\HttpUtility; -use TYPO3\CMS\Frontend\Http\UrlHandlerInterface; - -/** - * This class implements the hooks for the JumpURL functionality when accessing a page - * which has a GET parameter "jumpurl". - * It then validates the referrer - */ -class JumpUrlHandler implements UrlHandlerInterface -{ - /** - * @var string The current JumpURL value submitted in the GET parameters. - */ - protected $url; - - /** - * Return TRUE if this hook handles the current URL. - * Warning! If TRUE is returned content rendering will be disabled! - * This method will be called in the constructor of the TypoScriptFrontendController - * - * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::__construct() - * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::initializeCustomUrlHandlers() - * @return bool - */ - public function canHandleCurrentUrl() - { - $this->url = (string)GeneralUtility::_GP('jumpurl'); - return ($this->url !== ''); - } - - /** - * Custom processing of the current URL. - * - * If a valid hash was submitted the user will either be redirected - * to the given jumpUrl or if it is a secure jumpUrl the file data - * will be passed to the user. - * - * If canHandle() has returned TRUE this method needs to take care of redirecting the user or generating custom output. - * This hook will be called BEFORE the user is redirected to an external URL configured in the page properties. - * - * @see \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::processCustomUrlHandlers() - * @throws \RuntimeException if Jump URL was triggered by an illegal referrer. - * @return void - */ - public function handle() - { - if (!$this->referrerIsValid()) { - throw new \RuntimeException('The jumpUrl request was triggered by an illegal referrer.'); - } - - if ((bool)GeneralUtility::_GP('juSecure')) { - $this->forwardJumpUrlSecureFileData($this->url); - } else { - $this->redirectToJumpUrl($this->url); - } - } - - /** - * Returns TRUE if the current referrer allows Jump URL handling. - * This is the case then the referrer check is disabled or when the referrer matches the current TYPO3 host. - * - * @return bool if the referer is valid. - */ - protected function referrerIsValid() - { - if (!empty($GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer'])) { - return true; - } - - $referrer = parse_url(GeneralUtility::getIndpEnv('HTTP_REFERER')); - // everything is fine if no host is set, or the host matches the TYPO3_HOST - return (!isset($referrer['host']) || $referrer['host'] === GeneralUtility::getIndpEnv('TYPO3_HOST_ONLY')); - } - - - /** - * Redirects the user to the given jump URL if all submitted values - * are valid - * - * @param string $jumpUrl The URL to which the user should be redirected - * @throws \Exception - */ - protected function redirectToJumpUrl($jumpUrl) - { - $this->validateIfJumpUrlRedirectIsAllowed($jumpUrl); - - $pageTSconfig = $this->getTypoScriptFrontendController()->getPagesTSconfig(); - if (is_array($pageTSconfig['TSFE.'])) { - $pageTSconfig = $pageTSconfig['TSFE.']; - } else { - $pageTSconfig = array(); - } - - $jumpUrl = $this->addParametersToTransferSession($jumpUrl, $pageTSconfig); - $statusCode = $this->getRedirectStatusCode($pageTSconfig); - $this->redirect($jumpUrl, $statusCode); - } - - /** - * If the submitted hash is correct and the user has access to the - * related content element the contents of the submitted file will - * be output to the user. - * - * @param string $jumpUrl The URL to the file that should be output to the user - * @throws \Exception - */ - protected function forwardJumpUrlSecureFileData($jumpUrl) - { - // Set the parameters required for handling a secure jumpUrl link - // The locationData GET parameter, containing information about the record that created the URL - $locationData = (string)GeneralUtility::_GP('locationData'); - // The optional mimeType GET parameter - $mimeType = (string)GeneralUtility::_GP('mimeType'); - // The jump Url Hash GET parameter - $juHash = (string)GeneralUtility::_GP('juHash'); - - // validate the hash GET parameter against the other parameters - if ($juHash !== JumpUrlUtility::calculateHashSecure($jumpUrl, $locationData, $mimeType)) { - throw new \Exception('The calculated Jump URL secure hash ("juHash") did not match the submitted "juHash" query parameter.', 1294585196); - } - - if (!$this->isLocationDataValid($locationData)) { - throw new \Exception('The calculated secure location data "' . $locationData . '" is not accessible.', 1294585195); - } - - // Allow spaces / special chars in filenames. - $jumpUrl = rawurldecode($jumpUrl); - - // Deny access to files that match TYPO3_CONF_VARS[SYS][fileDenyPattern] and whose parent directory - // is typo3conf/ (there could be a backup file in typo3conf/ which does not match against the fileDenyPattern) - $absoluteFileName = GeneralUtility::getFileAbsFileName(GeneralUtility::resolveBackPath($jumpUrl), false); - - if ( - !GeneralUtility::isAllowedAbsPath($absoluteFileName) - || !GeneralUtility::verifyFilenameAgainstDenyPattern($absoluteFileName) - || GeneralUtility::isFirstPartOfStr($absoluteFileName, (PATH_site . 'typo3conf')) - ) { - throw new \Exception('The requested file was not allowed to be accessed through Jump URL. The path or file is not allowed.', 1294585194); - } - - try { - $resourceFactory = $this->getResourceFactory(); - $file = $resourceFactory->retrieveFileOrFolderObject($absoluteFileName); - $this->readFileAndExit($file, $mimeType); - } catch (\Exception $e) { - throw new \Exception('The requested file "' . $jumpUrl . '" for Jump URL was not found..', 1294585193); - } - } - - /** - * Checks if the given location data is valid and the connected record is accessible by the current user. - * - * @param string $locationData - * @return bool - */ - protected function isLocationDataValid($locationData) - { - $isValidLocationData = false; - list($pageUid, $table, $recordUid) = explode(':', $locationData); - $pageRepository = $this->getTypoScriptFrontendController()->sys_page; - $timeTracker = $this->getTimeTracker(); - if (empty($table) || $pageRepository->checkRecord($table, $recordUid, true)) { - // This check means that a record is checked only if the locationData has a value for a - // record else than the page. - if (!empty($pageRepository->getPage($pageUid))) { - $isValidLocationData = true; - } else { - $timeTracker->setTSlogMessage('LocationData Error: The page pointed to by location data "' . $locationData . '" was not accessible.', 2); - } - } else { - $timeTracker->setTSlogMessage('LocationData Error: Location data "' . $locationData . '" record pointed to was not accessible.', 2); - } - return $isValidLocationData; - } - - /** - * This implements a hook, e.g. for direct mail to allow the redirects but only if the handler says it's alright - * But also checks against the common juHash parameter first - * - * @param string $jumpUrl the URL to check - * @throws \Exception thrown if no redirect is allowed - */ - protected function validateIfJumpUrlRedirectIsAllowed($jumpUrl) - { - $allowRedirect = false; - if ($this->isJumpUrlHashValid($jumpUrl)) { - $allowRedirect = true; - } elseif ( - isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler']) - && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler']) - ) { - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['jumpurlRedirectHandler'] as $className) { - $hookObject = GeneralUtility::getUserObj($className); - if (method_exists($hookObject, 'jumpurlRedirectHandler')) { - $allowRedirect = $hookObject->jumpurlRedirectHandler($jumpUrl, $GLOBALS['TSFE']); - } - if ($allowRedirect) { - break; - } - } - } - - if (!$allowRedirect) { - throw new \Exception('The calculated Jump URL hash ("juHash") did not match the submitted "juHash" query parameter.', 1359987599); - } - } - - /** - * Validate the jumpUrl hash against the GET/POST parameter "juHash". - * - * @param string $jumpUrl The URL to check against. - * @return bool - */ - protected function isJumpUrlHashValid($jumpUrl) - { - return GeneralUtility::_GP('juHash') === JumpUrlUtility::calculateHash($jumpUrl); - } - - /** - * Calls the PHP readfile function and exits. - * - * @param FileInterface $file The file that should be read. - * @param string $mimeType Optional mime type override. If empty the automatically detected mime type will be used. - */ - protected function readFileAndExit($file, $mimeType) - { - $file->getStorage()->dumpFileContents($file, true, null, $mimeType); - exit; - } - - /** - * Simply calls the redirect method in the HttpUtility. - * - * @param string $jumpUrl - * @param int $statusCode - */ - protected function redirect($jumpUrl, $statusCode) - { - HttpUtility::redirect($jumpUrl, $statusCode); - } - - /** - * Modified the URL to go to by adding the session key information to it - * but only if TSFE.jumpUrl_transferSession = 1 is set via pageTSconfig. - * - * @param string $jumpUrl the URL to go to - * @param array $pageTSconfig the TSFE. part of the TS configuration - * - * @return string the modified URL - */ - protected function addParametersToTransferSession($jumpUrl, $pageTSconfig) - { - // allow to send the current fe_user with the jump URL - if (!empty($pageTSconfig['jumpUrl_transferSession'])) { - $uParts = parse_url($jumpUrl); - /** @noinspection PhpInternalEntityUsedInspection We need access to the current frontend user ID. */ - $params = '&FE_SESSION_KEY=' . - rawurlencode( - $this->getTypoScriptFrontendController()->fe_user->id . '-' . - md5( - $this->getTypoScriptFrontendController()->fe_user->id . '/' . - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] - ) - ); - // Add the session parameter ... - $jumpUrl .= ($uParts['query'] ? '' : '?') . $params; - } - return $jumpUrl; - } - - /** - * Returns one of the HTTP_STATUS_* constants of the HttpUtility that matches - * the configured HTTP status code in TSFE.jumpURL_HTTPStatusCode Page TSconfig. - * - * @param array $pageTSconfig - * @return string - * @throws \InvalidArgumentException If the configured status code is not valid. - */ - protected function getRedirectStatusCode($pageTSconfig) - { - $statusCode = HttpUtility::HTTP_STATUS_303; - - if (!empty($pageTSconfig['jumpURL_HTTPStatusCode'])) { - switch ((int)$pageTSconfig['jumpURL_HTTPStatusCode']) { - case 301: - $statusCode = HttpUtility::HTTP_STATUS_301; - break; - case 302: - $statusCode = HttpUtility::HTTP_STATUS_302; - break; - case 307: - $statusCode = HttpUtility::HTTP_STATUS_307; - break; - default: - throw new \InvalidArgumentException('The configured jumpURL_HTTPStatusCode option is invalid. Allowed codes are 301, 302 and 307.', 1381768833); - } - } - - return $statusCode; - } - - /** - * @return \TYPO3\CMS\Core\TimeTracker\TimeTracker - */ - protected function getTimeTracker() - { - return $GLOBALS['TT']; - } - - /** - * Returns an instance of the ResourceFactory. - * - * @return ResourceFactory - */ - protected function getResourceFactory() - { - return ResourceFactory::getInstance(); - } - - /** - * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController - */ - protected function getTypoScriptFrontendController() - { - return $GLOBALS['TSFE']; - } -} diff --git a/typo3/sysext/jumpurl/Classes/JumpUrlProcessor.php b/typo3/sysext/jumpurl/Classes/JumpUrlProcessor.php deleted file mode 100644 index fa3df5a885f1..000000000000 --- a/typo3/sysext/jumpurl/Classes/JumpUrlProcessor.php +++ /dev/null @@ -1,211 +0,0 @@ -<?php -namespace FoT3\Jumpurl; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Core\Utility\StringUtility; -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; -use TYPO3\CMS\Frontend\Http\UrlProcessorInterface; - -/** - * This class implements the hooks for creating jump URLs when links (typolink, mailtoLink) are built - */ -class JumpUrlProcessor implements UrlProcessorInterface -{ - /** - * @var ContentObjectRenderer - */ - protected $contentObjectRenderer; - - /** - * Generates the JumpURL for the given parameters. - * - * @see \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::processUrlModifiers() - * @param string $context The context in which the URL is generated (e.g. "typolink"). - * @param string $url The URL that should be processed. - * @param array $configuration The link configuration. - * @param \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObjectRenderer The calling content object renderer. - * @param bool $keepProcessing If this is set to FALSE no further hooks will be processed after the current one. - * @return string - */ - public function process($context, $url, array $configuration, ContentObjectRenderer $contentObjectRenderer, &$keepProcessing) - { - if (!$this->isEnabled($context, $configuration)) { - return $url; - } - - $this->contentObjectRenderer = $contentObjectRenderer; - - // Strip the absRefPrefix from the URLs. - $urlPrefix = (string)$this->getTypoScriptFrontendController()->absRefPrefix; - if ($urlPrefix !== '' && StringUtility::beginsWith($url, $urlPrefix)) { - $url = substr($url, strlen($urlPrefix)); - } - - // Make sure the slashes in the file URL are not encoded. - if ($context === UrlProcessorInterface::CONTEXT_FILE) { - $url = str_replace('%2F', '/', rawurlencode(rawurldecode($url))); - } - - $url = $this->build($url, isset($configuration['jumpurl.']) ? $configuration['jumpurl.'] : array()); - - // Now add the prefix again if it was not added by a typolink call already. - if ($urlPrefix !== '' && !StringUtility::beginsWith($url, $urlPrefix)) { - $url = $urlPrefix . $url; - } - - return $url; - } - - /** - * Returns TRUE if jumpurl was enabled in the global configuration - * or in the given configuration - * - * @param string $context separate check for the MAIL context needed - * @param array $configuration Optional jump URL configuration - * @return bool TRUE if enabled, FALSE if disabled - */ - protected function isEnabled($context, array $configuration = array()) - { - if (!empty($configuration['jumpurl.']['forceDisable'])) { - return false; - } - - $enabled = !empty($configuration['jumpurl']); - - // if jumpurl is explicitly set to 0 we override the global configuration - if (!$enabled && $this->getTypoScriptFrontendController()->config['config']['jumpurl_enable']) { - $enabled = !isset($configuration['jumpurl']) || $configuration['jumpurl']; - } - - // If we have a mailto link and jumpurl is not explicitly enabled - // but globally disabled for mailto links we disable it - if ( - empty($configuration['jumpurl']) && $context === UrlProcessorInterface::CONTEXT_MAIL - && $this->getTypoScriptFrontendController()->config['config']['jumpurl_mailto_disable'] - ) { - $enabled = false; - } - - return $enabled; - } - - - /** - * Builds a jump URL for the given URL - * - * @param string $url The URL to which will be jumped - * @param array $configuration Optional TypoLink configuration - * @return string The generated URL - */ - protected function build($url, array $configuration) - { - $urlParameters = array('jumpurl' => $url); - - // see if a secure File URL should be built - if (!empty($configuration['secure'])) { - $secureParameters = $this->getParametersForSecureFile( - $url, - isset($configuration['secure.']) ? $configuration['secure.'] : array() - ); - $urlParameters = array_merge($urlParameters, $secureParameters); - } else { - $urlParameters['juHash'] = JumpUrlUtility::calculateHash($url); - } - - $typoLinkConfiguration = array( - 'parameter' => $this->getTypoLinkParameter($configuration), - 'additionalParams' => GeneralUtility::implodeArrayForUrl('', $urlParameters), - // make sure jump URL is not called again - 'jumpurl.' => array('forceDisable' => '1') - ); - - return $this->getContentObjectRenderer()->typoLink_URL($typoLinkConfiguration); - } - - /** - * Returns a URL parameter array containing parameters for secure downloads by "jumpurl". - * Helper function for filelink() - * - * The array returned has the following structure: - * juSecure => is always 1, - * locationData => information about the record that created the jumpUrl, - * juHash => the hash that will be checked before the file is downloadable - * [mimeType => the mime type of the file] - * - * @param string $jumpUrl The URL to jump to, basically the filepath - * @param array $configuration TypoScript properties for the "jumpurl.secure" property of "filelink" - * @return array URL parameters required for jumpUrl secure - * - */ - protected function getParametersForSecureFile($jumpUrl, array $configuration) - { - $parameters = array( - 'juSecure' => 1, - 'locationData' => $this->getTypoScriptFrontendController()->id . ':' . $this->getContentObjectRenderer()->currentRecord - ); - - $pathInfo = pathinfo($jumpUrl); - if (!empty($pathInfo['extension'])) { - $mimeTypes = GeneralUtility::trimExplode(',', $configuration['mimeTypes'], true); - foreach ($mimeTypes as $mimeType) { - list($fileExtension, $mimeType) = GeneralUtility::trimExplode('=', $mimeType, false, 2); - if (strtolower($pathInfo['extension']) === strtolower($fileExtension)) { - $parameters['mimeType'] = $mimeType; - break; - } - } - } - $parameters['juHash'] = JumpUrlUtility::calculateHashSecure($jumpUrl, $parameters['locationData'], $parameters['mimeType']); - return $parameters; - } - - /** - * Checks if an alternative link parameter was configured and if not - * a default parameter will be generated based on the current page - * ID and type. - * When linking to a file this method is needed - * - * @param array $configuration Data from the TypoLink jumpurl configuration - * @return string The parameter for the jump URL TypoLink - */ - protected function getTypoLinkParameter(array $configuration) - { - $linkParameter = $this->getContentObjectRenderer()->stdWrapValue('parameter', $configuration); - - if (empty($linkParameter)) { - $frontendController = $this->getTypoScriptFrontendController(); - $linkParameter = $frontendController->id . ',' . $frontendController->type; - } - - return $linkParameter; - } - - /** - * @return \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController - */ - protected function getTypoScriptFrontendController() - { - return $GLOBALS['TSFE']; - } - - /** - * @return ContentObjectRenderer - */ - protected function getContentObjectRenderer() - { - return $this->contentObjectRenderer ?: $this->getTypoScriptFrontendController()->cObj; - } -} diff --git a/typo3/sysext/jumpurl/Classes/JumpUrlUtility.php b/typo3/sysext/jumpurl/Classes/JumpUrlUtility.php deleted file mode 100644 index 7ffe60627ef2..000000000000 --- a/typo3/sysext/jumpurl/Classes/JumpUrlUtility.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -namespace FoT3\Jumpurl; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Core\Utility\GeneralUtility; - -/** - * This class contains functions for generating and validating jump URLs - */ -class JumpUrlUtility -{ - /** - * Calculates the hash for the given jump URL - * - * @param string $jumpUrl The target URL - * @return string The calculated hash - */ - public static function calculateHash($jumpUrl) - { - return GeneralUtility::hmac($jumpUrl, 'jumpurl'); - } - - /** - * Calculates the hash for the given jump URL secure data. - * - * @param string $jumpUrl The URL to the file - * @param string $locationData Information about the record that rendered the jump URL, format is [pid]:[table]:[uid] - * @param string $mimeType Mime type of the file or an empty string - * @return string The calculated hash - */ - public static function calculateHashSecure($jumpUrl, $locationData, $mimeType) - { - $data = array((string)$jumpUrl, (string)$locationData, (string)$mimeType); - return GeneralUtility::hmac(serialize($data)); - } -} diff --git a/typo3/sysext/jumpurl/Documentation/.gitignore b/typo3/sysext/jumpurl/Documentation/.gitignore deleted file mode 100644 index 6cd159f2dad9..000000000000 --- a/typo3/sysext/jumpurl/Documentation/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -# this is file .gitignore - -# ignore everything in this directory -_make/* - -# but do not ignore this file -!_not_versioned/.gitignore diff --git a/typo3/sysext/jumpurl/Documentation/Configuration/Index.rst b/typo3/sysext/jumpurl/Documentation/Configuration/Index.rst deleted file mode 100644 index 5e817a3f1070..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Configuration/Index.rst +++ /dev/null @@ -1,208 +0,0 @@ -.. ================================================== -.. FOR YOUR INFORMATION -.. -------------------------------------------------- -.. -*- coding: utf-8 -*- with BOM. - -.. include:: ../Includes.txt - - -.. _configuration: - -Configuration -------------- - -This Extension is configured by global :ref:`TypoScript config <configuration-global>`, -:ref:`typolink options <configuration-global-jumpurl-enable>` and -:ref:`configuration-typo3-conf-vars`. - - -.. _configuration-global: - -Global TypoScript configuration -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -JumpURL can be configured globally in the ``config`` TypoScript namespace. - - -.. ### BEGIN~OF~TABLE ### - - -.. _configuration-global-jumpurl-enable: - -jumpurl\_enable -""""""""""""""" - -.. container:: table-row - - Property - jumpurl\_enable - - Data type - boolean - - Description - Enables JumpURL for all supported contexts for all generated links. - - -.. _configuration-global-jumpurl-mailto-disable: - -jumpurl\_mailto\_disable -"""""""""""""""""""""""" - -.. container:: table-row - - Property - jumpurl\_mailto\_disable - - Data type - boolean - - Description - Disables the use of JumpURL when linking to email-adresses. - - -.. ###### END~OF~TABLE ###### - - -.. _configuration-typolink: - -typolink settings -^^^^^^^^^^^^^^^^^ - -JumpURL options can be provided in the :ref:`typolink <t3tsref:typolink>` and the :ref:`filelink <t3tsref:filelink>` -configuration. - -The ``typolink`` options can be provided directly in the ``typolink`` namespace, e.g.: - -.. code-block:: typoscript - - mylink = TEXT - mylink.value = typo3.org - mylink.typolink.parameter = http://www.typo3.org - mylink.typolink.jumpurl = 1 - - -The :code:`filelink` options can be provided in the :code:`typolinkConfiguration` property: - -.. code-block:: typoscript - - mylink = TEXT - mylink.value = text.txt - mylink.filelink.path = fileadmin/ - mylink.filelink.typolinkConfiguration.jumpurl = 1 - - -The following options are available for JumpURLs. - - -.. ### BEGIN~OF~TABLE ### - - -.. _configuration-typolink-jumpurl: - -jumpurl -""""""" - -.. container:: table-row - - Property - jumpurl - - Data type - boolean - - Description - Enables JumpURL for the current link if it points to an external URL or a file. - - Please note that this does not work for internal links or for email links. - - To enable JumpURL for email links the global setting needs to be used. - - -.. _configuration-typolink-jumpurl-force-disable: - -jumpurl.forceDisable -"""""""""""""""""""" - -.. container:: table-row - - Property - jumpurl.forceDisable - - Data type - boolean - - Description - Disables JumpURL. - - This will override the global setting config.jumpurl_enable for the current link. - - -.. _configuration-typolink-jumpurl-secure: - -jumpurl.secure -"""""""""""""" - -.. container:: table-row - - Property - jumpurl.secure - - Data type - boolean - - Description - Enables JumpURL secure. This option is only available for file links. - - If set, then the file pointed to by jumpurl is **not** redirected to, but rather it's read - from the file and returned with a correct header. - - This option adds a hash and locationData to the URL and there MUST be access to the record - in order to download the file. - - If the file position on the server is furthermore secured by a .htaccess file preventing ANY - access, you've got secure download here! - - -.. _configuration-typolink-jumpurl-secure-mime-types: - -jumpurl.secure.mimeTypes -"""""""""""""""""""""""" - -.. container:: table-row - - Property - jumpurl.secure.mimeTypes - - Data type - string - - Description - With this option you can specify an alternative mime type that is sent in the HTTP Content-Type - header when the file is delivered to the user. By default the automatically detected mime type - will be used. - - Syntax: [ext] = [MIME type1], [ext2] = [MIME type2], ... - - **Example:** - - .. code-block:: typoscript - - jumpurl.secure = 1 - jumpurl.secure.mimeTypes = pdf=application/pdf, doc=application/msword - - -.. ###### END~OF~TABLE ###### - - -.. _configuration-typo3-conf-vars: - -TYPO3_CONF_VARS -^^^^^^^^^^^^^^^ - -The setting :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['doNotCheckReferer']` can be used to disable -the referer check during jumpurl handling. By default the referring host must match the current -host, otherwise processing is stopped. - -The setting :php:`$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey']` is used for generating -the hashes submitted in the URLs. \ No newline at end of file diff --git a/typo3/sysext/jumpurl/Documentation/Includes.txt b/typo3/sysext/jumpurl/Documentation/Includes.txt deleted file mode 100644 index 38aa39832f7e..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Includes.txt +++ /dev/null @@ -1,21 +0,0 @@ -.. ================================================== -.. FOR YOUR INFORMATION -.. -------------------------------------------------- -.. -*- coding: utf-8 -*- with BOM. - -.. This is 'Includes.txt'. It is included at the very top of each and - every ReST source file in this documentation project (= manual). - - -.. ================================================== -.. DEFINE SOME TEXTROLES -.. -------------------------------------------------- - -.. role:: typoscript(code) - -.. role:: ts(typoscript) - :class: typoscript - -.. role:: php(code) - -.. highlight:: php diff --git a/typo3/sysext/jumpurl/Documentation/Index.rst b/typo3/sysext/jumpurl/Documentation/Index.rst deleted file mode 100644 index 16ba3ce9a787..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Index.rst +++ /dev/null @@ -1,60 +0,0 @@ -.. ================================================== -.. FOR YOUR INFORMATION -.. -------------------------------------------------- -.. -*- coding: utf-8 -*- with BOM. - -.. include:: Includes.txt - - -.. _start: - -======== -JumpURL -======== - -:Extension key: - jumpurl - -:Version: - |release| - -:Language: - en - -:Description: - Allows to modify links to create Jump URLs created in the frontend of the TYPO3 Core. - -:Keywords: - jumpurl, sysext - -:Copyright: - 2015 - -:Author: - TYPO3 CMS Core Development Team - -:License: - Open Content License available from `www.opencontent.org/opl.shtml - <http://www.opencontent.org/opl.shtml>`_ - -:Rendered: - |today| - -The content of this document is related to TYPO3, - -a GNU/GPL CMS/Framework available from `www.typo3.org -<http://www.typo3.org/>`_ - - - - -**Table of Contents** - -.. toctree:: - :maxdepth: 5 - :titlesonly: - :glob: - - Introduction/Index - Configuration/Index - Targets diff --git a/typo3/sysext/jumpurl/Documentation/Introduction/Index.rst b/typo3/sysext/jumpurl/Documentation/Introduction/Index.rst deleted file mode 100644 index 64cb3486eede..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Introduction/Index.rst +++ /dev/null @@ -1,57 +0,0 @@ -.. ================================================== -.. FOR YOUR INFORMATION -.. -------------------------------------------------- -.. -*- coding: utf-8 -*- with BOM. - -.. include:: ../Includes.txt - - - -.. _introduction: - -Introduction ------------- - -**Hint!** The JumpURL functionality is deprecated and might be removed in future versions. - - -.. _what-does-it-do: - -What does it do? -^^^^^^^^^^^^^^^^ - -This Extension bundles the JumpURL functionality of TYPO3. JumpURL consists of -two components: link tracking and secure file access. - - -.. _introduction-link-tracking: - -Link tracking -^^^^^^^^^^^^^ - -The redirection to external URLs will be handled by a request to TYPO3. This allows the tracking -of clicks on links to external pages. Such a URL might look like this: - -http://mytypo3.tld/index.php?id=1&jumpurl=http%3A%2F%2Fwww.typo3.org&juHash=XXX - -When this URL is processed by TYPO3 the user will be redirected to http://www.typo3.org if -the sumitted juHash is valid. - -The same functionality can be used for file and email links. - - -.. _introduction-secure-file-access: - -Secure file access -^^^^^^^^^^^^^^^^^^ - -JumpURL can also make files downloadable that are not directly accessible by the web server. -This feature is called "JumpURL secure". - -A secure JumpURL link will deliver a file if the submitted hash matches. The record that -references the file needs to be accessible by the current user. When the referencing -record is removed or hidden the file will not be delivered to the user any more. - - - - diff --git a/typo3/sysext/jumpurl/Documentation/Settings.yml b/typo3/sysext/jumpurl/Documentation/Settings.yml deleted file mode 100644 index 89d21ccab7cd..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Settings.yml +++ /dev/null @@ -1,15 +0,0 @@ -# This is the project specific Settings.yml file. -# Place Sphinx specific build information here. -# Settings given here will replace the settings of 'conf.py'. - ---- -conf.py: - copyright: 2015 - project: JumpURL - version: 1 - release: 1 - intersphinx_mapping: - t3tsref: - - http://docs.typo3.org/typo3cms/TyposcriptReference/ - - null -... diff --git a/typo3/sysext/jumpurl/Documentation/Targets.rst b/typo3/sysext/jumpurl/Documentation/Targets.rst deleted file mode 100644 index c7c43c0bb448..000000000000 --- a/typo3/sysext/jumpurl/Documentation/Targets.rst +++ /dev/null @@ -1,13 +0,0 @@ -.. ================================================== -.. FOR YOUR INFORMATION -.. -------------------------------------------------- -.. -*- coding: utf-8 -*- with BOM. - -.. include:: Includes.txt - -.. _index-labels-for-crossreferencing: - -Index: Labels for Crossreferencing -================================== - -.. ref-targets-list:: diff --git a/typo3/sysext/jumpurl/Tests/Unit/ContentObjectRendererTest.php b/typo3/sysext/jumpurl/Tests/Unit/ContentObjectRendererTest.php deleted file mode 100644 index bb0bcc44295b..000000000000 --- a/typo3/sysext/jumpurl/Tests/Unit/ContentObjectRendererTest.php +++ /dev/null @@ -1,401 +0,0 @@ -<?php -namespace FoT3\Jumpurl\Tests\Unit; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use Psr\Log\LoggerInterface; -use TYPO3\CMS\Core\Charset\CharsetConverter; -use TYPO3\CMS\Core\Database\DatabaseConnection; -use TYPO3\CMS\Core\Log\LogManager; -use TYPO3\CMS\Core\TimeTracker\TimeTracker; -use TYPO3\CMS\Core\TypoScript\TemplateService; -use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; -use TYPO3\CMS\Frontend\Page\PageRepository; -use FoT3\Jumpurl\JumpUrlHandler; -use FoT3\Jumpurl\JumpUrlProcessor; - -/** - * Testcase for the jumpurl processing in TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer. - */ -class ContentObjectRendererTest extends \TYPO3\CMS\Core\Tests\UnitTestCase -{ - /** - * @var array A backup of registered singleton instances - */ - protected $singletonInstances = array(); - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer - */ - protected $subject = null; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\TypoScript\TemplateService - */ - protected $templateServiceMock = null; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface - */ - protected $typoScriptFrontendControllerMock = null; - - /** - * Set up - */ - protected function setUp() - { - $this->singletonInstances = GeneralUtility::getSingletonInstances(); - $this->createMockedLoggerAndLogManager(); - - $this->templateServiceMock = $this->getMock(TemplateService::class, array('getFileName')); - $pageRepositoryMock = $this->getMock(PageRepository::class, array('getPage')); - - $this->typoScriptFrontendControllerMock = $this->getAccessibleMock(TypoScriptFrontendController::class, array('dummy'), array(), '', false); - $this->typoScriptFrontendControllerMock->tmpl = $this->templateServiceMock; - $this->typoScriptFrontendControllerMock->config = array(); - $this->typoScriptFrontendControllerMock->page = array(); - $this->typoScriptFrontendControllerMock->sys_page = $pageRepositoryMock; - $this->typoScriptFrontendControllerMock->csConvObj = new CharsetConverter(); - $this->typoScriptFrontendControllerMock->renderCharset = 'utf-8'; - $GLOBALS['TSFE'] = $this->typoScriptFrontendControllerMock; - - $GLOBALS['TT'] = $this->getMock(TimeTracker::class, array('dummy')); - - $GLOBALS['TYPO3_DB'] = $this->getMock(DatabaseConnection::class, array()); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; - - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors']['jumpurl']['processor'] = JumpUrlProcessor::class; - $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers']['jumpurl']['handler'] = JumpUrlHandler::class; - - $this->subject = $this->getAccessibleMock( - ContentObjectRenderer::class, - array('getResourceFactory', 'getEnvironmentVariable'), - array($this->typoScriptFrontendControllerMock) - ); - $this->subject->start(array(), 'tt_content'); - } - - protected function tearDown() - { - GeneralUtility::resetSingletonInstances($this->singletonInstances); - parent::tearDown(); - } - - /** - * @test - */ - public function filelinkCreatesCorrectJumpUrlSecureForFileWithUrlEncodedSpecialChars() - { - $testData = $this->initializeJumpUrlTestEnvironment($this->once()); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - $fileName = substr($fileNameAndPath, strlen(PATH_site . 'typo3temp/')); - - $expectedHash = '304b8c8e022e92e6f4d34e97395da77705830818'; - $expectedLink = htmlspecialchars($testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode(str_replace('%2F', '/', rawurlencode($relativeFileNameAndPath))) . '&juSecure=1&locationData=' . rawurlencode($testData['locationData']) . '&juHash=' . $expectedHash); - - $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => '1', 'jumpurl.' => array('secure' => 1))); - $this->assertEquals('<a href="' . $expectedLink . '">' . $fileName . '</a>', $result); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function filelinkCreatesCorrectSecureJumpUrlIfConfigured() - { - $testData = $this->initializeJumpUrlTestEnvironment($this->once()); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - $fileName = substr($fileNameAndPath, strlen(PATH_site . 'typo3temp/')); - - $expectedHash = '1933f3c181db8940acfcd4d16c74643947179948'; - $expectedLink = htmlspecialchars($testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($relativeFileNameAndPath) . '&juSecure=1&locationData=' . rawurlencode($testData['locationData']) . '&juHash=' . $expectedHash); - - $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => '1', 'jumpurl.' => array('secure' => 1))); - $this->assertEquals('<a href="' . $expectedLink . '">' . $fileName . '</a>', $result); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function filelinkDisablesGlobalJumpUrlIfConfigured() - { - $testData = $this->initializeJumpUrlTestEnvironment($this->never()); - - $fileName = 'phpunitJumpUrlTestFile.txt'; - $fileNameAndPath = 'typo3temp/' . $fileName; - file_put_contents(PATH_site . $fileNameAndPath, 'Some test data'); - - $expectedLink = $testData['absRefPrefix'] . $fileNameAndPath; - $expectedLink = '<a href="' . $expectedLink . '">' . $fileName . '</a>'; - - // Test with deprecated configuration, TODO: remove when deprecated code is removed! - $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => 0)); - $this->assertEquals($expectedLink, $result); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function filelinkDisablesGlobalJumpUrlWithDeprecatedOptionIfConfigured() - { - $testData = $this->initializeJumpUrlTestEnvironment($this->never()); - - $fileName = 'phpunitJumpUrlTestFile.txt'; - $fileNameAndPath = 'typo3temp/' . $fileName; - file_put_contents(PATH_site . $fileNameAndPath, 'Some test data'); - - $expectedLink = $testData['absRefPrefix'] . $fileNameAndPath; - $expectedLink = '<a href="' . $expectedLink . '">' . $fileName . '</a>'; - - // Test with deprecated configuration - $result = $this->subject->filelink($fileName, array('path' => 'typo3temp/', 'jumpurl' => 0)); - $this->assertEquals($expectedLink, $result); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function makeHttpLinksCreatesCorrectJumpUrlIfConfigured() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $testUrl = 'http://www.mytesturl.tld'; - $expectedHash = '7d2261b12682a4b73402ae67415e09f294b29a55'; - - $expectedLinkFirstPart = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testUrl); - $expectedLinkSecondPart = '&juHash=' . $expectedHash; - - // due to a bug in the jump URL generation in the old version only - // the first part of the link is encoded which does not make much sense. - $expectedLink = htmlspecialchars($expectedLinkFirstPart . $expectedLinkSecondPart); - - $result = $this->subject->http_makelinks('teststring ' . $testUrl . ' anotherstring', array('keep' => 'scheme')); - $this->assertEquals('teststring <a href="' . $expectedLink . '">' . $testUrl . '</a> anotherstring', $result); - } - - /** - * @test - */ - public function makeMailtoLinksCreatesCorrectJumpUrlIfConfigured() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $testMail = 'mail@ddress.tld'; - $testMailto = 'mailto:' . $testMail; - $expectedHash = 'bd82328dc40755f5d0411e2e16e7c0cbf33b51b7'; - $expectedLink = htmlspecialchars($testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testMailto) . '&juHash=' . $expectedHash); - $result = $this->subject->mailto_makelinks('teststring ' . $testMailto . ' anotherstring', array()); - - $this->assertEquals('teststring <a href="' . $expectedLink . '">' . $testMail . '</a> anotherstring', $result); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForExternalUrl() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $testAddress = 'http://external.domain.tld'; - $expectedHash = '8591c573601d17f37e06aff4ac14c78f107dd49e'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testAddress) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => $testAddress)); - - $this->assertEquals($expectedUrl, $generatedUrl); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForExternalUrlWithUrlEncodedParameters() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $testAddress = 'http://external.domain.tld?parameter1=' . rawurlencode('parameter[data]with&a lot-of-special/chars'); - $expectedHash = 'cfc95f583da7689238e98bbc8930ebd820f0d20f'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testAddress) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => $testAddress)); - - $this->assertEquals($expectedUrl, $generatedUrl); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForFile() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - - $testAddress = $relativeFileNameAndPath; - $expectedHash = 'e36be153c32f4d4d0db1414e47a05cf3149923ae'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testAddress) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => $testAddress)); - - $this->assertEquals($expectedUrl, $generatedUrl); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForFileWithSpecialUrlEncodedSpecialChars() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - - $testFileLink = $relativeFileNameAndPath; - $expectedHash = '691dbf63a21181e2d69bf78e61f1c9fd023aef2c'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode(str_replace('%2F', '/', rawurlencode($testFileLink))) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => str_replace('%2F', '/', rawurlencode($testFileLink)))); - - $this->assertEquals($expectedUrl, $generatedUrl); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForFileWithUrlEncodedSpecialChars() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - - $testFileLink = $relativeFileNameAndPath; - $expectedHash = '691dbf63a21181e2d69bf78e61f1c9fd023aef2c'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode(str_replace('%2F', '/', rawurlencode($testFileLink))) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => rawurlencode($testFileLink))); - - $this->assertEquals($expectedUrl, $generatedUrl); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectJumpUrlForMail() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $testAddress = 'mail@ddress.tld'; - $expectedHash = 'bd82328dc40755f5d0411e2e16e7c0cbf33b51b7'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode('mailto:' . $testAddress) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => $testAddress)); - - $this->assertEquals($expectedUrl, $generatedUrl); - } - - /** - * @test - */ - public function typoLinkCreatesCorrectSecureJumpUrlForFile() - { - $testData = $this->initializeJumpUrlTestEnvironment(); - - $fileNameAndPath = PATH_site . 'typo3temp/phpunitJumpUrlTestFile.txt'; - file_put_contents($fileNameAndPath, 'Some test data'); - $relativeFileNameAndPath = substr($fileNameAndPath, strlen(PATH_site)); - - $testAddress = $relativeFileNameAndPath; - $expectedHash = '1933f3c181db8940acfcd4d16c74643947179948'; - $expectedUrl = $testData['absRefPrefix'] . $testData['mainScript'] . '?id=' . $testData['pageId'] . '&type=' . $testData['pageType'] . '&jumpurl=' . rawurlencode($testAddress) . '&juSecure=1&locationData=' . rawurlencode($testData['locationData']) . '&juHash=' . $expectedHash; - $generatedUrl = $this->subject->typoLink_URL(array('parameter' => $testAddress, 'jumpurl.' => array('secure' => 1))); - - $this->assertEquals($expectedUrl, $generatedUrl); - - GeneralUtility::unlink_tempfile($fileNameAndPath); - } - - /** - * Avoid logging to the file system (file writer is currently the only configured writer) - */ - protected function createMockedLoggerAndLogManager() - { - /** @var \TYPO3\CMS\Core\SingletonInterface $logManagerMock */ - $logManagerMock = $this->getMock(LogManager::class); - $loggerMock = $this->getMock(LoggerInterface::class); - $logManagerMock->expects($this->any()) - ->method('getLogger') - ->willReturn($loggerMock); - GeneralUtility::setSingletonInstance(LogManager::class, $logManagerMock); - } - - /** - * Initializes all required settings in $GLOBALS['TSFE'] and the current - * content object renderer for testing jump URL functionality. - * - * @param \PHPUnit_Framework_MockObject_Matcher_InvokedCount $expectedGetPageCalls - * @return array - */ - protected function initializeJumpUrlTestEnvironment($expectedGetPageCalls = null) - { - if (!isset($expectedGetPageCalls)) { - $expectedGetPageCalls = $this->once(); - } - - $testData = array(); - - $this->typoScriptFrontendControllerMock->config['config']['jumpurl_enable'] = true; - - $testData['pageId'] = $this->typoScriptFrontendControllerMock->id = '1234'; - $testData['pageType'] = $this->typoScriptFrontendControllerMock->type = '4'; - $testData['mainScript'] = $this->typoScriptFrontendControllerMock->config['mainScript'] = 'index.php'; - $testData['absRefPrefix'] = $this->typoScriptFrontendControllerMock->absRefPrefix = '/prefix/'; - $this->subject->currentRecord = 'tt_content:999'; - $testData['locationData'] = $testData['pageId'] . ':' . $this->subject->currentRecord; - - /** @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Frontend\Page\PageRepository $pageRepositoryMock */ - $pageRepositoryMock = $this->typoScriptFrontendControllerMock->sys_page; - $pageRepositoryMock->expects($expectedGetPageCalls) - ->method('getPage') - ->will($this->returnValue( - array( - 'uid' => $testData['pageId'], - 'doktype' => \TYPO3\CMS\Frontend\Page\PageRepository::DOKTYPE_DEFAULT, - 'url_scheme' => 0, - 'title' => 'testpage', - ) - ) - ); - - return $testData; - } -} diff --git a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlHandlerTest.php b/typo3/sysext/jumpurl/Tests/Unit/JumpUrlHandlerTest.php deleted file mode 100644 index 31ae4c062362..000000000000 --- a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlHandlerTest.php +++ /dev/null @@ -1,358 +0,0 @@ -<?php -namespace FoT3\Jumpurl\Tests\Unit; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Core\Resource\Exception\FileDoesNotExistException; -use TYPO3\CMS\Core\Resource\File; -use TYPO3\CMS\Core\Resource\ResourceFactory; -use TYPO3\CMS\Core\Utility\HttpUtility; -use TYPO3\CMS\Frontend\Authentication\FrontendUserAuthentication; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; -use FoT3\Jumpurl\JumpUrlHandler; - -/** - * Testcase for handling jump URLs when given with a test parameter - */ -class JumpUrlHandlerTest extends \TYPO3\CMS\Core\Tests\UnitTestCase -{ - /** - * The default location data used for JumpUrl secure. - * - * @var string - */ - protected $defaultLocationData = '1234:tt_content:999'; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|JumpUrlHandler - */ - protected $jumpUrlHandler; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController - */ - protected $tsfe; - - /** - * Sets environment variables and initializes global mock object. - */ - protected function setUp() - { - parent::setUp(); - - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; - - $this->jumpUrlHandler = $this->getMock( - JumpUrlHandler::class, - array('isLocationDataValid', 'getResourceFactory', 'getTypoScriptFrontendController', 'readFileAndExit', 'redirect') - ); - - $this->tsfe = $this->getAccessibleMock( - TypoScriptFrontendController::class, - array('getPagesTSconfig'), - array(), - '', - false - ); - $this->jumpUrlHandler->expects($this->any()) - ->method('getTypoScriptFrontendController') - ->will($this->returnValue($this->tsfe)); - } - - /** - * Provides a valid jump URL hash and a target URL - * - * @return array - */ - public function jumpUrlDefaultValidParametersDataProvider() - { - return array( - 'File with spaces and ampersands' => array( - '691dbf63a21181e2d69bf78e61f1c9fd023aef2c', - str_replace('%2F', '/', rawurlencode('typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt')), - ), - 'External URL' => array( - '7d2261b12682a4b73402ae67415e09f294b29a55', - 'http://www.mytesturl.tld', - ), - 'External URL with GET parameters' => array( - 'cfc95f583da7689238e98bbc8930ebd820f0d20f', - 'http://external.domain.tld?parameter1=' . rawurlencode('parameter[data]with&a lot-of-special/chars'), - ), - 'External URL without www' => array( - '8591c573601d17f37e06aff4ac14c78f107dd49e', - 'http://external.domain.tld', - ), - 'Mailto link' => array( - 'bd82328dc40755f5d0411e2e16e7c0cbf33b51b7', - 'mailto:mail@ddress.tld', - ) - ); - } - - /** - * @test - * @dataProvider jumpUrlDefaultValidParametersDataProvider - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlDefaultAcceptsValidUrls($hash, $jumpUrl) - { - $_GET['juHash'] = $hash; - $_GET['jumpurl'] = $jumpUrl; - - $this->jumpUrlHandler->expects($this->once()) - ->method('redirect') - ->with($jumpUrl, HttpUtility::HTTP_STATUS_303); - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @test - * @dataProvider jumpUrlDefaultValidParametersDataProvider - * @expectedException \Exception - * @expectedExceptionCode 1359987599 - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlDefaultFailsOnInvalidHash($hash, $jumpUrl) - { - $_GET['jumpurl'] = $jumpUrl; - $_GET['juHash'] = $hash . '1'; - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @test - * @dataProvider jumpUrlDefaultValidParametersDataProvider - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlDefaultTransfersSession($hash, $jumpUrl) - { - $tsConfig['TSFE.']['jumpUrl_transferSession'] = 1; - - /** @var \PHPUnit_Framework_MockObject_MockObject|FrontendUserAuthentication $frontendUserMock */ - $frontendUserMock = $this->getMock(FrontendUserAuthentication::class); - $frontendUserMock->id = 123; - - $this->tsfe->_set('fe_user', $frontendUserMock); - $this->tsfe->expects($this->once()) - ->method('getPagesTSconfig') - ->will($this->returnValue($tsConfig)); - - $sessionGetParameter = (strpos($jumpUrl, '?') === false ? '?' : '') . '&FE_SESSION_KEY=123-fc9f825a9af59169895f3bb28267a42f'; - $expectedJumpUrl = $jumpUrl . $sessionGetParameter; - - $this->jumpUrlHandler->expects($this->once()) - ->method('redirect') - ->with($expectedJumpUrl, HttpUtility::HTTP_STATUS_303); - - $_GET['jumpurl'] = $jumpUrl; - $_GET['juHash'] = $hash; - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * Provides a valid jump secure URL hash, a file path and related - * record data - * - * @return array - */ - public function jumpUrlSecureValidParametersDataProvider() - { - return array( - array( - '1933f3c181db8940acfcd4d16c74643947179948', - 'typo3temp/phpunitJumpUrlTestFile.txt', - ), - array( - '304b8c8e022e92e6f4d34e97395da77705830818', - str_replace('%2F', '/', rawurlencode('typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt')), - ), - array( - '304b8c8e022e92e6f4d34e97395da77705830818', - str_replace('%2F', '/', rawurlencode('typo3temp/phpunitJumpUrlTestFile with spaces & amps.txt')), - ) - ); - } - - /** - * @test - * @dataProvider jumpUrlSecureValidParametersDataProvider - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlSecureAcceptsValidUrls($hash, $jumpUrl) - { - $_GET['jumpurl'] = $jumpUrl; - $this->prepareJumpUrlSecureTest($hash); - - $fileMock = $this->getMock(File::class, array('dummy'), array(), '', false); - $resourceFactoryMock = $this->getMock(ResourceFactory::class, array('retrieveFileOrFolderObject')); - - $resourceFactoryMock->expects($this->once()) - ->method('retrieveFileOrFolderObject') - ->will($this->returnValue($fileMock)); - - $this->jumpUrlHandler->expects($this->once()) - ->method('isLocationDataValid') - ->with($this->defaultLocationData) - ->will($this->returnValue(true)); - - $this->jumpUrlHandler->expects($this->once()) - ->method('getResourceFactory') - ->will($this->returnValue($resourceFactoryMock)); - - $this->jumpUrlHandler->expects($this->once()) - ->method('readFileAndExit') - ->with($fileMock); - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @test - * @dataProvider jumpUrlSecureValidParametersDataProvider - * @expectedException \Exception - * @expectedExceptionCode 1294585193 - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlSecureFailsIfFileDoesNotExist($hash, $jumpUrl) - { - $_GET['jumpurl'] = $jumpUrl; - $this->prepareJumpUrlSecureTest($hash); - - $resourceFactoryMock = $this->getMock(ResourceFactory::class, array('retrieveFileOrFolderObject')); - $resourceFactoryMock->expects($this->once()) - ->method('retrieveFileOrFolderObject') - ->will($this->throwException(new FileDoesNotExistException())); - - $this->jumpUrlHandler->expects($this->once()) - ->method('isLocationDataValid') - ->with($this->defaultLocationData) - ->will($this->returnValue(true)); - - $this->jumpUrlHandler->expects($this->once()) - ->method('getResourceFactory') - ->will($this->returnValue($resourceFactoryMock)); - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @test - * @dataProvider jumpUrlSecureValidParametersDataProvider - * @expectedException \Exception - * @expectedExceptionCode 1294585195 - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlSecureFailsOnDeniedAccess($hash, $jumpUrl) - { - $_GET['jumpurl'] = $jumpUrl; - $this->prepareJumpUrlSecureTest($hash); - - $this->jumpUrlHandler->expects($this->once()) - ->method('isLocationDataValid') - ->with($this->defaultLocationData) - ->will($this->returnValue(false)); - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @test - * @dataProvider jumpUrlSecureValidParametersDataProvider - * @expectedException \Exception - * @expectedExceptionCode 1294585196 - * @param string $hash - * @param string $jumpUrl - */ - public function jumpUrlSecureFailsOnInvalidHash($hash, $jumpUrl - ) { - $_GET['juSecure'] = '1'; - $_GET['juHash'] = $hash . '1'; - $_GET['locationData'] = $this->defaultLocationData; - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @return array - */ - public function jumpUrlSecureFailsOnForbiddenFileLocationDataProvider() - { - return array( - 'totally forbidden' => array( - '/a/totally/forbidden/path' - ), - 'typo3conf file' => array( - PATH_site . '/typo3conf/path' - ), - 'file with forbidden character' => array( - PATH_site . '/mypath/test.php' - ) - ); - } - - /** - * @test - * @dataProvider jumpUrlSecureFailsOnForbiddenFileLocationDataProvider - * @expectedException \Exception - * @expectedExceptionCode 1294585194 - * @param string $path - * @param string $path - */ - public function jumpUrlSecureFailsOnForbiddenFileLocation($path) - { - $this->jumpUrlHandler->expects($this->once()) - ->method('isLocationDataValid') - ->with('') - ->will($this->returnValue(true)); - - - $hash = \FoT3\Jumpurl\JumpUrlUtility::calculateHashSecure($path, '', ''); - - $_GET['jumpurl'] = $path; - $_GET['juSecure'] = '1'; - $_GET['juHash'] = $hash; - $_GET['locationData'] = ''; - - $this->jumpUrlHandler->canHandleCurrentUrl(); - $this->jumpUrlHandler->handle(); - } - - /** - * @param string $hash - * @return void - */ - protected function prepareJumpUrlSecureTest($hash) - { - $_GET['juSecure'] = '1'; - $_GET['juHash'] = $hash; - $_GET['locationData'] = $this->defaultLocationData; - } -} diff --git a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorMock.php b/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorMock.php deleted file mode 100644 index f352367dcba5..000000000000 --- a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorMock.php +++ /dev/null @@ -1,35 +0,0 @@ -<?php -namespace FoT3\Jumpurl\Tests\Unit; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use FoT3\Jumpurl\JumpUrlProcessor; - -/** - * Testcase for handling jump URLs when given with a test parameter - */ -class JumpUrlProcessorMock extends JumpUrlProcessor -{ - /** - * Makes the parent getParametersForSecureFile() method accessible. - * - * @param string $jumpUrl - * @param array $configuration - * @return array - */ - public function getParametersForSecureFile($jumpUrl, array $configuration) - { - return parent::getParametersForSecureFile($jumpUrl, $configuration); - } -} diff --git a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorTest.php b/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorTest.php deleted file mode 100644 index 51c49dce376c..000000000000 --- a/typo3/sysext/jumpurl/Tests/Unit/JumpUrlProcessorTest.php +++ /dev/null @@ -1,101 +0,0 @@ -<?php -namespace FoT3\Jumpurl\Tests\Unit; - -/* - * This file is part of the TYPO3 CMS project. - * - * It is free software; you can redistribute it and/or modify it under - * the terms of the GNU General Public License, either version 2 - * of the License, or any later version. - * - * For the full copyright and license information, please read the - * LICENSE.txt file that was distributed with this source code. - * - * The TYPO3 project - inspiring people to share! - */ - -use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer; -use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; - -/** - * Testcase for handling jump URLs when given with a test parameter - */ -class JumpUrlProcessorTest extends \TYPO3\CMS\Core\Tests\UnitTestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject|ContentObjectRenderer - */ - protected $contentObjectRenderer; - - /** - * The default location data used for JumpUrl secure. - * - * @var string - */ - protected $defaultLocationData = '1234:tt_content:999'; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|JumpUrlProcessorMock - */ - protected $jumpUrlProcessor; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Core\Tests\AccessibleObjectInterface|\TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController - */ - protected $tsfe; - - /** - * Sets environment variables and initializes global mock object. - */ - protected function setUp() - { - parent::setUp(); - - $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'] = '12345'; - - $this->jumpUrlProcessor = $this->getMock( - JumpUrlProcessorMock::class, - array('getTypoScriptFrontendController', 'getContentObjectRenderer') - ); - - $this->tsfe = $this->getAccessibleMock( - TypoScriptFrontendController::class, - array('getPagesTSconfig'), - array(), - '', - false - ); - $this->jumpUrlProcessor->expects($this->any()) - ->method('getTypoScriptFrontendController') - ->will($this->returnValue($this->tsfe)); - - $this->contentObjectRenderer = $this->getMock(ContentObjectRenderer::class); - $this->jumpUrlProcessor->expects($this->any()) - ->method('getContentObjectRenderer') - ->will($this->returnValue($this->contentObjectRenderer)); - } - - /** - * @test - */ - public function getJumpUrlSecureParametersReturnsValidParameters() - { - $this->tsfe->id = 456; - $this->contentObjectRenderer->currentRecord = 'tt_content:123'; - - $jumpUrlSecureParameters = $this->jumpUrlProcessor->getParametersForSecureFile( - '/fileadmin/a/test/file.txt', - array('mimeTypes' => 'dummy=application/x-executable,txt=text/plain') - ); - - $this->assertSame( - array( - 'juSecure' => 1, - 'locationData' => '456:tt_content:123', - 'mimeType' => 'text/plain', - 'juHash' => '1cccb7f01c8a3f58ee890377b5de9bdc05115a37', - ), - $jumpUrlSecureParameters - ); - } -} diff --git a/typo3/sysext/jumpurl/composer.json b/typo3/sysext/jumpurl/composer.json deleted file mode 100644 index 3fe4118d0eac..000000000000 --- a/typo3/sysext/jumpurl/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "friendsoftypo3/jumpurl", - "type": "typo3-cms-extension", - "description": "TYPO3 Jump URL handling", - "homepage": "https://typo3.org", - "license": ["GPL-2.0+"], - - "require": { - "typo3/cms-core": "~7.5", - "typo3/cms-frontend": "~7.5" - }, - "replace": { - "jumpurl": "*" - }, - "autoload": { - "psr-4": { - "FoT3\\Jumpurl\\": "Classes/" - } - }, - "autoload-dev": { - "psr-4": { - "FoT3\\Jumpurl\\Tests\\": "Tests/" - } - } -} diff --git a/typo3/sysext/jumpurl/ext_emconf.php b/typo3/sysext/jumpurl/ext_emconf.php deleted file mode 100644 index ed93ee713e9d..000000000000 --- a/typo3/sysext/jumpurl/ext_emconf.php +++ /dev/null @@ -1,21 +0,0 @@ -<?php -$EM_CONF[$_EXTKEY] = array( - 'title' => 'JumpURL', - 'description' => 'Allows to modify links to create Jump URLs created in the frontend of the TYPO3 Core.', - 'category' => 'fe', - 'author' => 'Friends of TYPO3', - 'author_email' => 'friendsof@typo3.org', - 'state' => 'stable', - 'uploadfolder' => 0, - 'createDirs' => '', - 'clearCacheOnLoad' => 1, - 'author_company' => '', - 'version' => '7.6.0', - 'constraints' => array( - 'depends' => array( - 'typo3' => '7.6.0-7.99.99', - ), - 'conflicts' => array(), - 'suggests' => array(), - ), -); diff --git a/typo3/sysext/jumpurl/ext_icon.png b/typo3/sysext/jumpurl/ext_icon.png deleted file mode 100644 index ef81ce288743eabb87151fa3dc79fbbbc95b2e1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3450 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 diff --git a/typo3/sysext/jumpurl/ext_localconf.php b/typo3/sysext/jumpurl/ext_localconf.php deleted file mode 100644 index c610e05e4244..000000000000 --- a/typo3/sysext/jumpurl/ext_localconf.php +++ /dev/null @@ -1,11 +0,0 @@ -<?php -defined('TYPO3_MODE') or die(); - -// Register hooks -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlProcessors']['jumpurl']['processor'] = \FoT3\Jumpurl\JumpUrlProcessor::class; -$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['urlProcessing']['urlHandlers']['jumpurl'] = [ - 'handler' => \FoT3\Jumpurl\JumpUrlHandler::class, - 'before' => [ - 'frontendExternalUrl' - ], -]; -- GitLab