|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-21 09:44 UTC] xdecock at gmail dot com
[2010-12-21 14:40 UTC] emiel dot bruijntjes at copernica dot com
[2010-12-21 16:24 UTC] xdecock at gmail dot com
[2010-12-22 04:25 UTC] emiel dot bruijntjes at copernica dot com
[2017-04-01 19:32 UTC] tpunt@php.net
-Status: Open
+Status: Wont fix
[2017-04-01 19:32 UTC] tpunt@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 20:00:01 2025 UTC |
Description: ------------ I think something is wrong with the internal memory management of the elements that are added to the bbcode parser. We have a website with multiple items that make use of bbcode. We create a single bbcode resource, add elements and smilies to it, and then call bbcode_parse() a couple of times in a row to convert bbcode'd text into HTML. However: the output of bbcode_parse() is not always the same: sometimes the [url] tags are converted into <a href> tags, but at other times the method returns the original bbcode, and does not do any conversion at all. I have created a tiny example script to reproduce the problem. I am aware that this script does not make much sense in a standalone environment, it is just the smallest possible example in which I run into this problem. (Thus: yes I know it is odd to call bbcode_add_element for elements that are already registered, but even if I do, it should not cause this unexpected behavior) Reproduce code: --------------- <?php function handleUrlParameter($param, $content) { return $content; } $options = array( 'sub' => array( 'type' => BBCODE_TYPE_NOARG, 'open_tag' => '<b>', 'close_tag' => '</b>', ), 'img' => array( 'type' => BBCODE_TYPE_OPTARG, ), 'url' => array( 'type' => BBCODE_TYPE_OPTARG, 'open_tag' => '<a href={PARAM}>', 'close_tag' => '</a>', 'param_handling' => 'handleUrlParameter', ), ); $parser = bbcode_create($options); $text = "this is an [url=http://google.com]example link[/url].\n"; for ($i=0; $i<1000; $i++) { foreach ($options as $tag => $option) bbcode_add_element($parser, $tag, $option); echo(bbcode_parse($parser, $text)); } Expected result: ---------------- I would expect 1000 lines with the text: this is an <a href=http://google.com>example link</a>. Actual result: -------------- I get to see two possible results: this is an <a href=http://google.com>example link</a>. this is an [url=http://google.com]example link[/url].