Issue Bug Rejected

#82963Editing of links with empty rel attribute causes exception in ckeditor

André Spindler 11/10/17, 10:17 updated 11/10/17, 11:20

Description

TYPO3: 8.7.8; composer installation
PHP: 7.0.22

Enabling the rel field in rte is easy:
buttons:
link:
relAttribute:
enabled: true

But if the rel attribute remains empty, editing of previously created links is not possible any more, this causes an exception.

Steps to reproduce:
  1. Enable rel attribute
  2. Create new link, leave rel attribute empty
  3. It is not neccessary to save changes, saving or not does not has an effect
  4. try to edit the new link – bang, exception
  5. switch to code view
  6. add something like ‘rel=“nofollow”’ to the link
  7. try to edit it again – ahhh, it works!

*Fix:*
Can’t try it at the moment, but adding a type check fur NULL and then setting $currentRel=”“ should work.
Something like

$currentRel = $currentRel ?: "";

before building the html code

*Backtrace:*
Uncaught TYPO3 Exception
htmlspecialchars() expects parameter 1 to be string, null given

TypeError thrown in file
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php in line 387.

14 htmlspecialchars(NULL)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php:
00385: ‘
00386:

00387: <input type="text" name="lrel" class="form-control" value="' . htmlspecialchars($currentRel) . '">
00388:

00389:

13 TYPO3\CMS\RteCKEditor\Controller\BrowseLinksController::getRelField()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php:
00356: $fieldRenderingDefinitions[‘class’] = $this->getClassField();
00357: $fieldRenderingDefinitions[‘target’] = $this->getTargetField();
00358: $fieldRenderingDefinitions[‘rel’] = $this->getRelField();
00359: if (empty($this->buttonConfig[‘queryParametersSelector’][‘enabled’])) {
00360: unset($fieldRenderingDefinitions[‘params’]);

12 TYPO3\CMS\RteCKEditor\Controller\BrowseLinksController::getLinkAttributeFieldDefinitions()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php:
00456: public function renderLinkAttributeFields()
00457: {
00458: $fieldRenderingDefinitions = $this->getLinkAttributeFieldDefinitions();
00459:
00460: $fieldRenderingDefinitions = $this->displayedLinkHandler->modifyLinkAttributes($fieldRenderingDefinitions);

11 TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController::renderLinkAttributeFields()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/rte_ckeditor/Classes/Controller/BrowseLinksController.php:
00271: }
00272: }
00273: return parent::renderLinkAttributeFields();
00274: }
00275:

10 TYPO3\CMS\RteCKEditor\Controller\BrowseLinksController::renderLinkAttributeFields()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/recordlist/Classes/Controller/AbstractLinkBrowserController.php:
00164:
00165: $menuData = $this->buildMenuArray();
00166: $renderLinkAttributeFields = $this->renderLinkAttributeFields();
00167: $browserContent = $this->displayedLinkHandler->render($request);
00168:

9 TYPO3\CMS\Recordlist\Controller\AbstractLinkBrowserController::mainAction(TYPO3\CMS\Core\Http\ServerRequest, TYPO3\CMS\Core\Http\Response)

8 call_user_func_array(array, array)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RouteDispatcher.php:
00052: $targetIdentifier = $route->getOption(‘target’);
00053: $target = $this->getCallableFromTarget($targetIdentifier);
00054: return call_user_func_array($target, [$request, $response]);
00055: }
00056:

7 TYPO3\CMS\Backend\Http\RouteDispatcher::dispatch(TYPO3\CMS\Core\Http\ServerRequest, TYPO3\CMS\Core\Http\Response)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RequestHandler.php:
00137: /** @var RouteDispatcher $dispatcher */
00138: $dispatcher = GeneralUtility::makeInstance(RouteDispatcher::class);
00139: return $dispatcher->dispatch($request, $response);
00140: }
00141: }

6 TYPO3\CMS\Backend\Http\RequestHandler::dispatch(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/RequestHandler.php:
00070: // Check if the router has the available route and dispatch.
00071: try {
00072: return $this->dispatch($request);
00073: } catch (InvalidRequestTokenException $e) {
00074: // When token was invalid redirect to login

5 TYPO3\CMS\Backend\Http\RequestHandler::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/core/Classes/Core/Bootstrap.php:
00313:
00314: // Execute the command which returns a Response object or NULL
00315: $this->response = $requestHandler->handleRequest($request);
00316: return $this;
00317: }

4 TYPO3\CMS\Core\Core\Bootstrap::handleRequest(TYPO3\CMS\Core\Http\ServerRequest)
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Classes/Http/Application.php:
00090: }
00091:
00092: $this->bootstrap->handleRequest($this->request);
00093:
00094: if ($execute !== null) {

3 TYPO3\CMS\Backend\Http\Application::run()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Resources/Private/Php/backend.php:
00022: $classLoader = require DIR . ‘/../../../../../../vendor/autoload.php’;
00023:
00024: (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00025: });

2 {closure}()
/var/www/vhosts/###/vendor/typo3/cms/typo3/sysext/backend/Resources/Private/Php/backend.php:
00023:
00024: (new \TYPO3\CMS\Backend\Http\Application($classLoader))->run();
00025: });

1 require(“/var/www/vhosts/###/vendor/typo3/cm…3/sysext/backend/Resources/Private/Php/backend.php”)
/var/www/vhosts/###/vendor/typo3/cms/typo3/index.php:
00001: <?php
00002:
00003: require DIR . ‘/sysext/backend/Resources/Private/Php/backend.php’;

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.