Issue Feature Under Review Quiet

#78560Loosen restrictions on tagnames in GeneralUtility::array2xml

Johannes Hertenstein 11/03/16, 15:30 updated 10/15/26, 20:54

Description

GeneralUtility::array2xml is very restrictive when it comes to tagnames. Currently only alphanumeric characters, ‘-’ and ‘_’ are allowed in tagnames which makes working with FlexForms or namespaced XML impossible (because ‘.’ and ‘:’ are discarded).

The following line is responsible for the restriction:

// The tag name is cleaned up so only alphanumeric chars (plus - and _) are in there and not longer than 100 chars either.
$tagName = substr(preg_replace('/[^[:alnum:]_-]/', '', $tagName), 0, 100);

There are multiple ways this could be handled in the future:

1. Lift restriction to match the W3 XML spec: https://www.w3.org/TR/2008/REC-xml-20081126/#NT-Name ( potentially breaking )
2. Add an option to explicitly allow certain characters. The resulting call could look like this:

GeneralUtility::array2xml($array, $NSprefix, $level, $docTag, $spaceInd, [ 'allowInTagName' => ['.', ':'] ]);

Reviews 1

History 56

  1. Markus Klein commented and changed tracker Bug Feature category <span data-processor="relativetime" data-value="2018-02-28T13:56:50+00:00" > 02/28/18, 13:56 </span>

    I suggest option two. Add an additional configuration option. Feel free to push a patch.

  2. Benni Mack commented <span data-processor="relativetime" data-value="2019-06-17T08:45:01+00:00" > 06/17/19, 08:45 </span>

    Markus Klein wrote:
    > I suggest option two. Add an additional configuration option. Feel free to push a patch.

    I’d go with option 1 and make it “breaking”, I don’t see how this could be breaking though.