Issue Bug Closed

#88059Uncaught TYPO3 Exception: htmlspecialchars() expects parameter 1 to be string, null given | TypeError thrown in file /srv/[pathto]/RequestHandler.php

Jan Loderhose 04/03/19, 10:28 updated 05/07/19, 12:10

Description

Including an external css file with @import via includeCSS or includeCSSLibs results in an uncaught TYPO3 exception if the optional property media is not set. (https://docs.typo3.org/typo3cms/TyposcriptReference/Setup/Page/Index.html#includecss-array)

Example:

page.includeCSS {
  css = https://some.external/css/file.css
  css.external = 1
  css.import = 1
  css.media = some value #not optional atm
}

Conditional usage of $cssFileConfig[‘media’] can solve this issue.

I suggest to change lines 490 and 532 of RequestHandler.php from

$pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($cssFileConfig['media']) . ';', empty($cssFileConfig['disableCompression']), (bool)$cssFileConfig['forceOnTop']);

to

$pageRenderer->addCssInlineBlock('import_' . $key, '@import url("' . htmlspecialchars($ss) . '") ' . htmlspecialchars($cssFileConfig['media'] ?  $cssFileConfig['media']:'') . ';', empty($cssFileConfig['disableCompression']), (bool)$cssFileConfig['forceOnTop']);

Reviews 2