I've got a regex that does matching for a template system, which unfortunately seems to crash apache (it's running on Windows) on some modestly-trivial lookups. I've researched the issue and there are a few suggestions for upping stack size etc, none of which seem to work and I don't really like dealing with such issues by upping limits anyway as it generally just pushed the bug into the future.
Anyway any ideas on how to alter the regex to make it less likely to foul up?
The idea is to catch the innermost block (in this case {block:test}This should be caught first!{/block:test}) which I'll then str_replace out the starting/ending tags and re-run the whole thing through the regex until there are no blocks left.
Regex:
~(?P<opening>{(?P<inverse>[!])?block:(?P<name>[a-z0-9\s_-]+)})(?P<contents>(?:(?!{/?block:[0-9a-z-_]+}).)*)(?P<closing>{/block:\3})~ism
Sample template:
<div class="f_sponsors s_banners">
<div class="s_previous">«</div>
<div class="s_sponsors">
<ul>
{block:sponsors}
<li>
<a href="{var:url}" target="_blank">
<img src="image/160x126/{var:image}" alt="{var:name}" title="{var:name}" />
</a>
{block:test}This should be caught first!{/block:test}
</li>
{/block:sponsors}
</ul>
</div>
<div class="s_next">»</div>
</div>
It's a long shot I suppose. :(