Feature #78560
openLoosen restrictions on tagnames in GeneralUtility::array2xml
0%
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' => ['.', ':'] ]);
Updated by Tymoteusz Motylewski about 8 years ago
- Category set to FormEngine aka TCEforms
Updated by Markus Klein over 6 years ago
- Tracker changed from Bug to Feature
- Category changed from FormEngine aka TCEforms to Backend API
I suggest option two. Add an additional configuration option. Feel free to push a patch.
Updated by Benni Mack over 5 years ago
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.