Home » HTML » HTML_BBCodeParser » Bug #3690
BBCodeParser does not allow numbers in the opening tag
Details
| Submitted | 2005-03-03 15:40 UTC |
|---|---|
| From | sintemaa at hotmail dot com |
| Assigned | quipo |
| Status | Closed |
| Package | HTML_BBCodeParser |
| PHP Version | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-03-03 15:40 UTC] sintemaa at hotmail dot com
Description:
------------
BBCodeParser does not allow numbers in the opening tag.
I added a new filter in which I added [h1] which should parse to <h1>
However it did not parse the opening tag, only the closing tag, which was then properly ignored cause there was no opening tag.
When digging into the code of the parser I found that in BBCodeParse.php on line 309 & 319 it uses a regular expression to grab the tags which only looks for a-z(linenumbers according to the cvs.php.net source browser which as a matter of fact messes up the comments in the header of the file, which means I get different linenumbers in my editor)
Currently on line 309:
if (preg_match("!$oe([a-z]+)[^$ce]*$ce!i", $str, $tagArray) == 0) {
Changing it to the following makes it parse tags with numbers aswell:
if (preg_match("!$oe([a-z0-9]+)[^$ce]*$ce!i", $str, $tagArray) == 0) {
Same fix required for line 319
Reproduce code:
---------------
New filter with:
var $_definedTags = array( 'h1' => array( 'htmlopen' => 'h1',
'htmlclose' => 'h1',
'allowed' => 'all',
'attributes'=> array()),
Use the parser, with the new filter enabled:
$parser->qparse('[h1]This is a header[/h1]');
Expected result:
----------------
<h1>this is a header</h1>
Actual result:
--------------
[h1]this is a header