Topic: Nested BBCode Bug

I already searched the forum but surprisingly couldn't find the problem listed anywhere (maybe just tried wrong search words...).
If I use nested tags inside a list tag, the inner one gets broken.

Example (the two whitespaces are just to be able to post it here as only one link per post is allowed):

[*][url=ht tp://ww]Example[/url][/*]

Results in:

You can see that the " of the url are escaped. That is due to the "e" modifier used for preg_replace of the list tag (parser.php, function do_bbcode):

        $pattern[] = '%\[list(?:=([1a*]))?+\]((?:(?>.*?(?=\[list(?:=[1a*])?+\]|\[/list\]))|(?R))*)\[/list\]%ise';
        $replace[] = 'handle_list_tag(\'$2\', \'$1\')';

The PHP documentation says about the e modifier:


The addslashes() function is run on each matched backreference before the substitution takes place. As such, when the backreference is used as a quoted string, escaped characters will be converted to literals. However, characters which are escaped, which would normally not be converted, will retain their slashes. This makes use of this modifier very complicated.

I'm not sure whether stripslashes() would simply solve the problem or might cause other problems depending on the content. What do you think?

I guess a clean solution would be to changing it to preg_replace_callback as the e modifier is deprecated anyways.

Re: Nested BBCode Bug

preg_replace() a deprecated feature. you need to replace it with preg_replace_callback()
Is uniquely!