[TYPO3-project-formidable] Template Engine: Bug when using isLoggedIn().isFalse() twice
Jerome Schneider
typo3dev at ameos.com
Fri Mar 6 15:22:46 CET 2009
Note:
in the pattern, I added a "?" after the central [^\1]* that you came up
with. This "?" mean: non greedy, in other words: please work on the
smallest possible subpart matching the pattern, not the largest one.
Happy coding,
Jerome
Jerome Schneider a écrit :
> Hi Hauke !
> I reproduced the bug.
>
> I just corrected it :) it took me 3 hours, but here is the correct pattern:
>
> /\<\!\-\-.*(\#\#\#(.+)\
> \bperimeter\b\#\#\#).*\-\-\>([^\1]*?)\<\!\-\-.*\1.*\-\-\>/
>
> It's published in revision 2.0.236 (I have committed to SVN but not
> built it as zip or T3X yet).
>
>
> I tested it against this template, and everything was processed correctly.
>
>
> I hope you can confirm the resolution. Thanks for reporting, btw !
>
> Best regards,
> Jerome Schneider
>
> <!-- ###MAIN### begin-->
>
> <h3>DEBUT</H3>
>
> <!-- ###"hello".equals("world") perimeter### begin-->
> <H2>NON 1</H2>
> <!-- ###"hello".equals("world") perimeter### end-->
>
> <h3>INTER1</H3>
>
> <!-- ###"hello".equals("hello") perimeter### begin-->
> <H2>OUI 1</H2>
>
> <!-- ###"yes".equals("yes") perimeter### begin-->
> <H2>OUI 1.1</H2>
>
> <!-- ###"abc".equals("abc") perimeter### begin-->
> <H2>OUI 1.1.1</H2>
> <!-- ###"abc".equals("abc") perimeter### end-->
>
> <!-- ###"abc".equals("xyz") perimeter### begin-->
> <H2>NON 1.1.2</H2>
> <!-- ###"abc".equals("xyz") perimeter### end-->
>
> <!-- ###"abc".equals("abc") perimeter### begin-->
> <H2>OUI 1.1.3</H2>
> <!-- ###"abc".equals("abc") perimeter### end-->
>
> <!-- ###"yes".equals("yes") perimeter### end-->
>
> <!-- ###"yes".equals("no") perimeter### begin-->
> <H2>NON 1.1</H2>
> <!-- ###"yes".equals("no") perimeter### end-->
>
> <!-- ###"hello".equals("hello") perimeter### end-->
>
> <h3>INTER2</H3>
>
> <!-- ###"hello".equals("world") perimeter### begin-->
> <H2>NON 2</H2>
> <!-- ###"hello".equals("world") perimeter### end-->
>
> <h3>INTER3</H3>
>
> <!-- ###"hello".equals("hello") perimeter### begin-->
> <H2>OUI 2</H2>
> <!-- ###"hello".equals("hello") perimeter### end-->
>
> <h3>FIN</H3>
>
> <!-- ###MAIN### end-->
>
> Note
>
> Hauke Hain a écrit :
>> Hi,
>>
>> I am not quite sure why my templates does not work with formidable
>> without changing the pattern.
>>
>> If I do not change it to $sPattern = '/\<\!\-\-.*(\#\#\#(.+)\
>> \bperimeter\b\#\#\#).*begin\-\-\>([^\\1.]*)\<\!\-\-.*\\1.*end\-\-\>/';
>> I do not get anything displayed.
>>
>> However, can you repeat the Bug? I think the whole thing would work
>> with replace instead of using regular expressions, as TYPO3 uses it.
>>
>> If it is ok, you may change the $pattern to my version. It is a bit
>> more specific and the groups are different. And it works for me only.
>> On the other hand: Can you imagine why this happens to me? Perhaps you
>> see something I don't (within the other posts in this thread).
>>
>> Thank you in advance.
>>
>> Kind regards,
>> Hauke
>>
>> "Hauke Hain" <newgrp at googlemail.com> schrieb im Newsbeitrag
>> news:mailman.1.1235588293.18628.typo3-project-formidable at lists.netfielders.de...
>>
>>> Regular Expressions are powerful, but not easy to understand.
>>>
>>> I do not understand how the function processPerimetersCallBack is
>>> called.
>>>
>>> It is calles via
>>> $sHtml = preg_replace_callback(
>>> $sPattern,
>>> array(
>>> &$this,
>>> "processPerimetersCallBack"
>>> ),
>>> $sHtml,
>>> -1 // no limit
>>> );
>>>
>>> But how does it get its parameter?
>>>
>>>
>>>
>>> The problem with processPerimeters is, that Match[3] contents the
>>> whole content from the first <!-- ###isLoggedIn().isFalse()
>>> perimeter### begin--> to the last <!-- ###isLoggedIn().isFalse()
>>> perimeter### end-->....
>>>
>>>
>>> And sorry, I said a few hours ago, that this only happens with
>>> isLoggedIn().isFalse() - it seems to happen with every condition
>>> which is used more than once.
>>>
>>>
>>>
>>> I changed in the regular expression that not every a-z and A-Z
>>> charackter is ok, but every charackter that is not the first
>>> group-string:
>>> [^\\1.]
>>>
>>> Replace
>>> $sPattern = '/\<\!\-\-.*(\#\#\#(.+)\
>>> \bperimeter\b\#\#\#).*begin\-\-\>([\w\W]*)\<\!\-\-.*\\1.*end\-\-\>/';
>>> with
>>> $sPattern = '/\<\!\-\-.*(\#\#\#(.+)\
>>> \bperimeter\b\#\#\#).*begin\-\-\>([^\\1.]*)\<\!\-\-.*\\1.*end\-\-\>/';
>>>
>>>
>>> Now everything is shown and nothing left, but *some* parts are shown,
>>> that shouldn't.
>>>
>>> The first <!-- ###isLoggedIn().isFalse() perimeter### begin--> ...
>>> <!-- ###isLoggedIn().isFalse() perimeter### end--> Part is shown or
>>> hidden as it should be.
>>>
>>> The second Part is always shown.
>>>
>>> At least nothing is left anymore.
>>>
>>> I hope you can fix the rest. That was enough for today.
>>>
>>> Sincerely,
>>> Hauke
>>>
>>
More information about the TYPO3-project-formidable
mailing list