1 (edited by keeshii 2013-09-17 19:01)

Topic: parser.php - tags, that musn't be closed.

I tried to add to bbcode some new tags, which don't have closing element. I added name of tag to array $tags_open and not to $tags_closed, but parser keep telling me, that I haven't closed my new tag during validation.

I suggest to change this fragment of code in parser.php:

@@ -480,13 +486,16 @@
             }
 
             if (in_array($current_tag, array_keys($tags_limit_bbcode)))
                 $limit_bbcode = $tags_limit_bbcode[$current_tag];
 
-            $open_tags[] = $current_tag;
-            $open_args[] = $current_arg;
-            $opened_tag++;
+            // add open_tags to stack only if they must be closed.
+            if (!in_array($current_tag, $tags_opened) || in_array($current_tag, $tags_closed)) {
+                $open_tags[] = $current_tag;
+                $open_args[] = $current_arg;
+                $opened_tag++;
+            }
             $new_text .= $current;
             continue;
         }
     }

This did the trick for me.

I know that arrays $tags_open and $tags_closed are equal, but now it is hard to make an extension, which adds non-closing tags into bbcode.

If you want to contact me quickly - send e-mail, not PM.
<?php $t='<?php $t=%c%s%c; printf($t,39,$t,39,10);%c'; printf($t,39,$t,39,10);

Re: parser.php - tags, that musn't be closed.

keeshi, can you make example for non-closed tag?

Re: parser.php - tags, that musn't be closed.

Install this extension: om_close_tag_test.zip. It adds the tag "username", which will be replaced by the name of user displaying the forum.

Now try to write a message like this:

Hello [username]! Your name is [username], right?

And the following error will be displayed:

[username] was opened within itself, this is not allowed
If you want to contact me quickly - send e-mail, not PM.
<?php $t='<?php $t=%c%s%c; printf($t,39,$t,39,10);%c'; printf($t,39,$t,39,10);