Issue Bug Closed

#107188dataWrap fails with TypeError when file title contains quotation mark followed by number (with any characters in between)

Wolfgang Wagner 07/31/25, 20:03 updated 03/31/26, 09:00

Description

When using dataWrap to include file titles in HTML attributes, TYPO3 throws a TypeError if the file title contains a quotation mark followed by a number, regardless of characters in between (e.g., “Reflecting Colonialism” – Berlin, 2011).

Steps to Reproduce:

Activate lightbox rendering via Constants or Settings (FluidStyledContent, e.g. use the EXT:styleguide demo tree and then adjust it via Site Settings).

Add an image reference to a content element, with title: German and Dutch participants during the study trip “Reflecting Colonialism” – Berlin, 2011 (© Philipp Abel)

Use this TypoScript configuration (e.g. by creating a custom site set or editing the EXT:styleguide setup.typoscript file to include this setting; or using sys_template based rendering):

lib.contentElement.settings.media.popup.linkParams.ATagParams.dataWrap = data-fancybox="fancybox" data-caption="{file:current:title}"

Render the content element in frontend

Expected Result:

HTML attribute should be generated correctly: data-caption=“German and Dutch participants during the study trip “Reflecting Colonialism” – Berlin, 2011 (© Philipp Abel)”

Actual Result:

TypeError: strtolower(): Argument #1 ($string) must be of type string, int given

Error Details:

(1/1) TypeError
strtolower(): Argument #1 ($string) must be of type string, int given

in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 1018
at TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes()

Pattern Analysis:

The issue occurs with the pattern: “[any characters][number] anywhere in the title. The quotation mark doesn’t need to be directly adjacent to the number.

Workaround:

lib.contentElement.settings.media.popup.linkParams.ATagParams.dataWrap {
  wrap = data-fancybox="fancybox" data-caption="|"
  cObject = COA
  cObject {
    10 = TEXT
    10.data = file:current:title
    10.htmlSpecialChars = 1
    10.if.isTrue.data = file:current:title
  }
}

More information about this error can be found here:
https://t3forum.net/d/958-kuriose-fehlermeldung-bei-einbindung-bild-mit-im-titel-feld

Reviews 2

Files 1

History 1214

  1. Wolfgang Wagner commented <span data-processor="relativetime" data-value="2025-07-31T20:10:22+00:00" > 07/31/25, 20:10 </span>

    Description

    When using dataWrap to include file titles in HTML attributes, TYPO3 throws a TypeError if the file title contains a quotation mark followed by a number, regardless of characters in between (e.g., “Reflecting Colonialism” – Berlin, 2011).

    Steps to Reproduce:

    Activate lightbox rendering via Constants or Settings.

    Add an image reference to a content element, with title: German and Dutch participants during the study trip “Reflecting Colonialism” – Berlin, 2011 (© Philipp Abel)

    Use this TypoScript configuration:

    lib.contentElement.settings.media.popup.linkParams.ATagParams.dataWrap = data-fancybox="fancybox" data-caption="{file:current:title}"

    Render the content element in frontend

    Expected Result:

    HTML attribute should be generated correctly: data-caption=“German and Dutch participants during the study trip "Reflecting Colonialism" – Berlin, 2011 (© Philipp Abel)”

    Actual Result:

    TypeError: strtolower(): Argument #1 ($string) must be of type string, int given

    Error Details:

    (1/1) TypeError
    strtolower(): Argument #1 ($string) must be of type string, int given

    in /var/www/html/vendor/typo3/cms-core/Classes/Utility/GeneralUtility.php line 1018
    at TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes()

    Pattern Analysis:

    The issue occurs with the pattern: “[any characters][number] anywhere in the title. The quotation mark doesn’t need to be directly adjacent to the number.

    Workaround:

    lib.contentElement.settings.media.popup.linkParams.ATagParams.dataWrap {
      wrap = data-fancybox="fancybox" data-caption="|" 
      cObject = COA
      cObject {
        10 = TEXT
        10.data = file:current:title
        10.htmlSpecialChars = 1
        10.if.isTrue.data = file:current:title
      }
    }

    More information about this error can be found here:
    https://t3forum.net/d/958-kuriose-fehlermeldung-bei-einbindung-bild-mit-im-titel-feld

  2. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-08-01T06:01:11+00:00" > 08/01/25, 06:01 </span>

    Hm, isn’t using quotes there a problem, too? Because it would yield invalid attributes and the actual issue could be we need to change the quote to a html entity instead?

  3. Wolfgang Wagner commented <span data-processor="relativetime" data-value="2025-08-01T06:04:20+00:00" > 08/01/25, 06:04 </span>

    Yes, of course, the quotation marks should be converted into HTML entities. Unfortunately, the editor did not display my code correctly.

    data-caption="German and Dutch participants during the study trip &quot;Reflecting Colonialism&quot; – Berlin, 2011 (© Philipp Abel)"
  4. Garvin Hicking commented and changed attached stacktrace.html <span data-processor="relativetime" data-value="2025-08-01T22:23:49+00:00" > 08/01/25, 22:23 </span>

    I’m afraid your workaround is probably how it’s better supposed to be utilized. ;)

    There’s a lot of quirkyness involved. Due to the quotes, the whole string is broken up into PHP array indexes:

    TYPO3\CMS\Core\Utility\GeneralUtility::implodeAttributes(array('href' => '/fileadmin/_processed_/1/f/csm_IMG_2922_95abcead8e.jpg', 'data-fancybox' => 'fancybox', 'data-caption' => 'German and Dutch participants during the study trip ', 'reflecting' => '', 'colonialism' => '', 'berlin' => '', '', 'philipp' => '', 'abel' => ''), true, true)

    and “2011” is actually then interpreted as an integer, not a string (PHP does this) and then the array structure is all build wonkily.

    I’m attaching a stacktrace here for further analysis, but this is probably going to be painful to address.

  5. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-08-01T22:42:59+00:00" > 08/01/25, 22:42 </span>

    The actual bug is that this string:

        <img class="image-embed-item" title="German and Dutch participants during the study trip &quot;Reflecting Colonialism&quot; – Berlin, 2011 (© Philipp Abel)"

    is wrongly interpretet; something (tm) treats the quot; as an actual quote again, and that’s burried deep in the stdWrap operations and “additionalAttribute” evaluation.

    So it already is broken due to the quotes, the additional number just reveals further processing mistakes in the internal PHP array, and we cannot force PHP to treat “2011” as a string instead of an integer.

    A solution would be to NOT treat the quot; as a quote when interpreting the ATagParams evaluation in stdWraps, but I’m fairly sure this will heavily break a lot of other stuff in stdWrap parsing. :-D

  6. Garvin Hicking commented <span data-processor="relativetime" data-value="2025-08-01T22:47:37+00:00" > 08/01/25, 22:47 </span>

    …. honestly I’d tend to reject this and advertise using your workaround; your solution has the advantage of strictly applying and joining the needed HTML parts with proper intents and less “automatic guessing with HTML attribute exploding+imploding”. What do you think? :-)

  7. Wolfgang Wagner commented <span data-processor="relativetime" data-value="2025-08-02T13:17:52+00:00" > 08/02/25, 13:17 </span>

    I cannot judge how time-consuming a change is here, or whether and where else this has an effect.

    The workaround works and I can live with it.

  8. Eric Harrer commented <span data-processor="relativetime" data-value="2026-03-03T22:51:52+00:00" > 03/03/26, 22:51 </span>

    Quick update after a deeper analysis: this turned out to be less complex than it first looked.

    The fatal error is caused by a very specific robustness gap, not by an unsolvable stdWrap design issue:

    • ATagParams is parsed into an attribute array.
    • With malformed/split input (for example unescaped quotes inside an attribute value), a numeric key can appear (e.g. 2011 as an integer key).
    • In GeneralUtility::implodeAttributes() (xhtmlSafe path), strtolower() was called on that key, which triggered the TypeError.

    So the fix is intentionally minimal:

    • cast attribute keys to string before strtolower()
    • add a regression test for the integer-key case

    For valid existing attribute keys, behavior stays the same.
    The patch only prevents a fatal error for malformed input.

  9. Eric Harrer commented and changed status Under Review Resolved done 0 % 100 % <span data-processor="relativetime" data-value="2026-03-04T09:15:09+00:00" > 03/04/26, 09:15 </span>

    Applied in changeset commit:b2ac1987e19508206a737b9302c2f0d455da9cb8.