Even weirder... I made a pyramid, and it doesn't fail at all. Everything works.
Posted: May 31st, 2012, 11:28 PM
Hmm, no, it removed too much actually. A bit.
Will fix asap.
This one seems to work fine...
if (!empty($settings['removeNestedQuotes']))
while (preg_match_all('~\[quote(.*?)]((?>[^[]|\[(?!/?quote))+)\[/quote]\n?~i', $form_message, $matches))
foreach ($matches[0] as $match)
$form_message = str_replace($match, '', $form_message);
It's not uber-optimized (if only because it does the replacement in X passes, with X = quote depth level), but at least it should be relatively safe with backtracking. I don't think it could lead to regex abuse. As I said above, I try to stay away from recursive regexes as much as possible these days, but it'd be great if you could do some quick benchmarking on heavy pyramids... (I don't think the performance difference will be noticeable if quote depth <= 1)
Posted: May 31st, 2012, 11:44 PM
:edit:
while (preg_match_all('~\[quote(.*?)](?>[^[]|\[(?!/?quote))*\[/quote]\n?~i', $form_message, $matches))
Should be a tiiiiny bit faster... (and take into account possible empty quotes.)
Posted: May 31st, 2012, 11:46 PM
And that.
while (preg_match_all('~\[quote(.*?)](?>[^[]|\[(?!/?quote))*\[/quote]\n?~i', $form_message, $matches))
$form_message = str_replace($matches[0], '', $form_message);
Funnier.