0

Using

  • Typo 3 (version 7.6.18)
  • Apache 2.4.23
  • OpenSSL/1.0.2h
  • PHP/7.0.10
  • MySQL 5.7.14
  • Windows 7

There appears to be a problem when rendering more than 20 items in a f:alias map when using the translate tag. The code is not converted to the expected markup and the f:alias code is shown on the page instead.

formfields.html mark-up

   <f:alias map="{exampleOptions:{
         0: {key: '', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.please_choose\' />'},
                        1: {key: '1', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionone\' />'},
                        2: {key: '2', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optiontwo\' />'},
                        3: {key: '3', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionthree\' />'},
                        4: {key: '4', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionfour\' />'},
                        5: {key: '5', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionfive\' />'},
                        6: {key: '6', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionsix\' />'},
                        7: {key: '7', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionseven\'/>'},
                        8: {key: '8', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optioneight\' />'},
                        9: {key: '9', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionnine\' />'},
                        10: {key: '10', value:'<f:translate key=\'tx_exampleextension_domain_model_complaintform.rel_optionten\' />'}
                    }}">

                        <f:form.select
                            class="form-control" 
                            property="example" options="{exampleOptions}"
                            optionValueField="key"
                            optionLabelField="value"
                        />

If there are more options added the map they are ignored and the page rendering stops.

The form partially renders but the alias mark-up is inserted as HTML instead of the transformed OPTION tag.

If the extra items are removed the page renders as it should.

It seems a very small amount of options for this to be happening, we have seen it on various machines, so it is not just related to one PC

Regolith
  • 2,944
  • 9
  • 33
  • 50

2 Answers2

0

It seems there is an issue with the regex used to parse the viewhelper tag.

If the Viewhelper tag is too long, this regex used here somehow does not match anymore.

Because I thought it had to do with your nesting at first, I tried to use a simplified version:

<f:alias map="{exampleOptions: '01234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789
                0123456789012345678901234
                '}">
    <f:debug>{exampleOptions}</f:debug>
</f:alias>

This was pretty much the limit of what it could handle (in my case). If I add a few characters I either get an error or the viewhelper is simply ignored (as it was with your case).

This is not limited to the f:alias ViewHelper but it looks like it affects any ViewHelper that has a tag that's too long.

The limit seems to be 2745 characters (from < to > inclusive).

Nitori
  • 669
  • 5
  • 11
0

The actual issue is the invalid quoting, the massive amount of nesting doesn't help.

Instead of diving into quoting hell I'd strongly recommend preparing the option keys and labels as array in your controller instead (you could e.g. use Extbase's LocalizationUtility for translating the labels) and then pass them into the template. Then you can skip the <f:alias/> completely.

Mathias Brodala
  • 5,905
  • 13
  • 30
  • Actually, it seems that there is an issue with parsing the viewhelper if the tag is too long. This is the limit of what still worked for me: https://gist.github.com/nitori/f5a88dbc746ae889984e17d700b5e6e6 If you add one character, you get an error, and if you add another character, the tag is simply printed without further parsing. – Nitori Jul 21 '17 at 13:31