HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Problem with Vanilla NBBC-parser


Can i ask something about the Vanilla NBBC-parser? (https://github.com/vanilla/nbbc/releases/tag/v2.2.3)

I have installed it with composer, and it works for the most part. But the Callback is doesn't working in PHP 7.2. In the example of the callback, i have used the autoloader in sttead of the old nbbc.php.

Simple tags are working, but the callback doenst working.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>Enhanced Tag Example</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

   require_once(__DIR__ . "/../vendor/autoload.php");
   use Nbbc\BBCode;

   $input = "[b]BOLD[/b] [border color=red size=3]This text is in a medium red border![/border]\n"
      . "[border size=10]This text is in a fat blue border![/border]\n"
      . "[border color=green]This text is in a normal green border![/border]\n";

   $bbcode = new BBCode();

   function MyBorderFunction($bbcode, $action, $name, $default, $params, $content) {
      if ($action == 'BBCODE_CHECK') {
         if (isset($params['color'])
            && !preg_match('/^#[0-9a-fA-F]+|[a-zA-Z]+$/', $params['color']))
            return false;
         if (isset($params['size'])
            && !preg_match('/^[1-9][0-9]*$/', $params['size']))
            return false;
         return true;

      $color = isset($params['color']) ? $params['color'] : "blue";
      $size = isset($params['size']) ? $params['size'] : 1;
      return "<div style=\"border: {$size}px solid $color\">$content</div>";

   $bbcode->AddRule('border', Array(
      'mode' => 'BBCODE_MODE_CALLBACK',
      'method' => 'MyBorderFunction',
      'class' => 'block',
      'allow_in' => Array('listitem', 'block', 'columns'),

   $output = $bbcode->Parse($input);

   print "<div class='bbcode'>$output</div>";


Bold is parsed als a bold text, but the callback for MyBorderFunction is doesn't working, and not parsed.



  • Options
    K17K17 Français / French Paris, France ✭✭✭

    Hi, be carefull here It's not BBCode, use the "Code" Burton in the editor to show us your code.

    Yet I didn't understood what you tried to do here. Are you trying to use this functuion outside Garden?

  • Options

    Hello, i want to place this NBBC UBB-parser in my own application. But the call-back functions doesn't working.

  • Options
    AarClayAarClay New
    edited October 2020

    I have tackled it.....


Sign In or Register to comment.