Issue Bug Closed

#102392YouTubeRenderer breaks on boolen html attribute without value

Henrik Elsner 11/17/23, 09:14 updated 11/09/26, 09:25

Description

Error message:
`PHP Runtime Deprecation Notice: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/html/vendor/typo3/cms-core/Classes/Resource/Rendering/YouTubeRenderer.php line 236`

Example code:

<f:media class="video-embed-item" file="{file}" alt="{file.alternative}" title="{file.title}"
         additionalAttributes="{playsinline:null, poster: posterimage}"/>

The playsinline attribute is without value thus causing the YouTubeRenderer to fail on evaulating.
IMHO it should be supported to handle the value = null
One could argue, that we should set playsinline to true, which then only sets the attribute name, but for the poster attribute in this case we would have to evaluate the posterimage object each time which can be annoying and expanding the code unnecessarily

Reviews 3

Files 1

History 37

  1. Stefan Bürk commented <span data-processor="relativetime" data-value="2024-01-16T01:45:16+00:00" > 01/16/24, 01:45 </span>

    IMO I would say `null` should not render that attribute at all, true = only name
    and otherwise the string casted value put through the sanatizer.

    Using “TRUE” and “NULL” for the same thing is compersome. On the otherhand, I don’t
    get why it would be proplem to write:

    <f:media
      class="video-embed-item" file="{file}" alt="{file.alternative}" title="{file.title}" 
      additionalAttributes="{playsinline:true, poster: posterimage}"
    />

    in the template oO

  2. Benni Mack commented and changed status Under Review Closed <span data-processor="relativetime" data-value="2026-11-09T09:25:44+00:00" > 11/09/26, 09:25 </span>

    Fixed on main and 14.3 by #95714 (f6d7f90c0c7 / 03650f2e890, Gerrit 84625): the media renderers now handle attribute values like Fluid’s TagBuilder. null and false omit the attribute, true renders a boolean attribute, so the htmlspecialchars() deprecation is gone. For a bare playsinline use {playsinline: true}; {playsinline: null} now leaves the attribute out. Closing as resolved.