Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Lists in BBCode borking comments

pbearpbear New
edited February 2007 in Vanilla 1.0 Help
(Long post here, so I'm going to break it up into three parts.)

I tried to test making an ordered and unordered list in a comment via BBCode, but something is wrong. I have the BetterBBCode 1.0 and BBInsertBar 0.1.5 extensions installed. I'm running this locally (nothing online atm) as I'm figuring out how Vanilla works. I searched here for BBCode posts, but didn't find this problem.

For unordered and ordered lists, respectively, BBInsertBar gives me:
[ulist] [*] [/ulist]
[list] [*] [/list]
I added additional items in the list part...:
[*]first item [*]second item [*]third item
Only the first got interpreted with a bullet (here, an "o"). The rest showed the raw BBCode:
o first item [*]second item [*]third item
I tried several things. Closing [/*] tags on each list item, etc. Nothing worked. Then I opened the BBCodeParser.php module and saw no * was listed, but li was.

So I entered it manually:
[ulist] [li]first item [li]second item [li]third item [/ulist]
This borked the layout seriously. I got a string of my avatar pic across one line. Then I immediately tried a second (now ordered) list. Foolish perhaps. This really messed the layout up. As the unordered list but worse.

Then I copied the source code and checked the nesting. The previous discussion ended ok:
<li> ... <div class="CommentBody" id="CommentBody_65">(comment text here)</div> </li>
The closing ol with id="Comments" and the closing div with id="ContentBody" that normally follow when this was the last message were improperly moved/removed, but after I added an unordered list using [li] instead of [*] for the list item marker.

(two more parts to go, continued...)


  • Options
    (continued, the code block)

    In this code block I've added comments indicating what needs to be removed, and at the end in a comment what tags should be added to fix the problem. When the code is adjusted this way, the page displays correctly once again (i.e. not a CSS styling glitch). Skip past the code block for the summary.

    Here's the comment section that begins the first unordered list post:
    <li id="Comment_66"> <a name="Item_3"></a> <div class="CommentHeader"> <ul> <li> <div class="CommentIcon" style="background-image: url(http://.../avatar.jpg);">&nbsp;</div> <span>CommentAuthor</span> <a href="http://.../account.php?u=1">pbear</a> </li> <li> <span>CommentTime</span>5 minutes ago </li> </ul> <span>&nbsp;Comment posted from <a href="http://.../post.php?CommentID=66">edit</a> <a id="HideComment66" href="./" onclick="HideComment('/forum/ajax/switch.php'>hide</a> <a onmousedown="quote(this);">quote</a><a href="#Item_3" id="Permalink_3">permalink</a> </span> </div> <div class="CommentBody" id="CommentBody_66"> <ul><br> <li>an unordered list<br></li> <li>that has li instead of *<br></li> <li>does it work?<br></li> </ul> <!-- 3 extra li sets were inserted here --> <li></li> <li></li> <li></li> <!-- these two are ok --> </div> </li> <!-- These two tags were improperly moved/removed/inserted: --> </ol> </div> <!-- next comment containing an ordered list starts like this --> <li id="Comment_67"> <a name="Item_4"></a> <div class="CommentHeader"> <!-- comment author info here... --> <!-- IP edit quote permalink here... --> </div> <div class="CommentBody" id="CommentBody_67"> yes ulist with li works!!!<br><br> <ul><br> <li>and ordered list<br></li> <li>that uses li instead of *<br></li> <li>does this work?<br></li> </ul> <!-- an additional 3 extra li's! were inserted here --> <li></li> <li></li> <li></li> </div> </li> <!-- this div is wrongly inserted --> </div> <li id="Comment_68"> <a name="Item_5"></a> <div class="CommentHeader"> <!-- comment author info here... --> <!-- IP edit quote permalink here... --> </div> <div class="CommentBody" id="CommentBody_68"> <!-- this is the content of a post made after the two above that messed things up --> <strong>(something here)</strong> </div> </li> <!-- this div is wrongly inserted --> </div> <!-- The following two tags must be added to properly finish nesting this block of comments </ol> </div> --> <!-- the final div/section begins properly --> <div class="ContentInfo Middle">
    (one more part to go, continued...)
  • Options
    (continued, conclusion)

    So... to fix, I had to:
    1. Remove the two blocks of three sets of li tags,
    2. Remove the ol and div closing tags that were placed after Comment_66,
    3. Remove the closing div tag at the end of the next two messages,
    4. Add the closing ol and div tags at the end of the last commment (68) but before the ContentInfo Middle opening div.
    There's the possibility that I've got something else going on. Basic Vanilla 1 install (albeit locally via MAMP/OS X) with some extensions going. Any clues?

    Besides the tag scrambling going on, I was also wondering:
    1. It is possible to get an ordered list? (hey, it's working here!)
    2. How would I switch back to using a single asterisk for lists (as detailed here: phpBB BBCode Guide)?
    3. Doesn't XHTML 1.0 Strict require empty tags to be self closed <br /> vs. <br> (as appears in the comment blocks above)?
    4. I'm sure it's possible but how would I modify the BBCodeParser to give me <quote> or <cite> tags with specific attributes, e.g.:
      [cite=marktwain] becomes <cite class="marktwain">
      [cite=kjv] becomes <cite class="kingjamesversion">
      ... which kind of thing might be useful for more boards focused on certain authors or texts. The different class attributes can then be singled out for styling easily via a custom stylesheet.
      (maybe someone could post what that BBCodeParser syntax would look like? :) )
  • Options
    Yeah that's a known issue; I've been trying to write a solution for a few weeks but it keeps chewing up my test cases.
  • Options
    :( but thanks for the reply. Is it definitely something in the BBCodeParser or could it be elsewhere?
  • Options
    The BBCodeParser home page, and here's a bug list. Is this the right one?

    In this particular bug comment, scroll down a bit to see Seth's note:
    I've fixed this bug and a number of others. Please take a look if you can, because I'd expect there to be new bugs in a rewrite of this size. (I'd call it version 2.0-beta)
    He's made an updated BBCodeParser file too.
  • Options
    edited July 2006
    I made some changes to the Pear BBCode parser, so it would be installable on machines without the whole Pear library, so don't overwrite the old file with this one unless you know what you're doing.
  • Options
    Heh, I've been digging around in those files and I tell you I know just enough to be dangerous. ;)

    From the BetterBBCode extension:
    //List $pattern = array( "!".$oe."\*".$ce."(.*)!i", "!".$oe."list".$ce."(.+)".$oe."/list".$ce."!isU"); $replace = array( $o."li".$c."\\1".$o."/li".$c, $o."ulist".$c."\\1".$o."/ulist".$c); $this->_preparsed = preg_replace($pattern, $replace, $this->_preparsed);
    I can't help but feel that that second part ($replace) is supposed to say ol instead of ulist. And that there should be another pattern/replace bit for ulist as it seems to start out for list.

    Found something better. Check the comment that refers to lists in the middle of the version 1.9 file available here ( It seems to be the same problem.

    To wit:
    /* why is this here? it just seems to break things * (nested lists where closing tags need to be * generated) while (end($tmpOpenTags)) { $tmpTag = $this->_buildTag('['.end($tmpOpenTags).']'); $newTagArray[] = $tmpTag; $openTags[] = $tmpTag['tag']; array_pop($tmpOpenTags); }*/
    Bonus: this seems to have integrated (all?) the changes from the file mentioned above (, done by the same guy).
  • Options
    Some good news:
    1. If you hide the discussion, it takes out all the messy code with it. Then you can edit it.
    2. [li] [/li] delimiters on the list item work.
    3. With the above delimiters, the br is properly encoded with a space before the closing slash.
    4. [ulist] and [list] both produce unordered lists
      (that's not really good news but I had a list going already).
  • Options
    in reading all the above greek gibberish has this been fixed in Vanilla 1 ?
  • Options
    It is not a problem with Vanilla, it is an issue with the BetterBBCode extension.
  • Options
    Bump. I also got the problem with the lists, as mentioned in the first comment of this discussion. Is there a solution?
  • Options
    It's taken me night on forever, but I think I've got unordered and ordered lists going I believe. What I've done also seems to fix the [*] splitting posts problem. Since [*] in random places doesn't appear between other valid tags in your post, it now just shows up as [*]. Vanilla 1.0.1 BBInsertBar 0.1.5 Better BBCode Extension 1.0 Open BetterBBCode/BBCodeParser.php and comment out like so // while (end($tmpOpenTags)) { // $tmpTag = $this->_buildTag('['.end($tmpOpenTags).']'); // $newTagArray[] = $tmpTag; // $openTags[] = $tmpTag['tag']; // array_pop($tmpOpenTags); // } I'm pretty sure those lines only appear once so you should be able to ID them. I've been going through the code section by section and commenting it up, so line numbers are no good now. Things I did that probably don't matter: - tried changing [*] to [item] in BBInsertBar/functions.js and BetterBBCode/BBCodeParser.php. It's not hard to do since [*] only appears a couple times. - tried to understand the printf types in the _definedTags section 'attributes'=> array('list' => 'type=%2$s%1$s%2$s', 's' => 'start=%2$s%1$d%2$s'). one of the list types has it, one doesn't. does not seem to make a difference, though for completeness fixing this probably is good someday (but not soon by me). - cleaned up both files so that functions.js produces [olist] and [ulist] tags for ordered and unordered lists. changed valid types and the regex section in BBCodeParser.php to match. i just though 'list' was a bad word to be sprinkling around all over. It's too late and I'm too tired to test this on a stock install. I know it's working for me. If this doesn't work reply here and I'll take another look, or post my file, or something like that. Time to go. It's the biggest bar night of the year and I've been at my desk for too long! -akira
  • Options
    Thanks! I shall try this and see how it goes :D
  • Options
    OK, whatever I understood from you didn't work, but I did go and download the latest BBCodeParser.php from the PHP website and hacked it into something working \o/

    I can now have nested lists that work, it's a miracle. I've probably opened up my forums to god knows what security vulnerabilities as I haven't got a blind clue what I really did, but I don't really care as their internal anyhow :) Let me just tidy things up a little bit (and check that I haven't broken other parts) then I'll post the file.
  • Options
    OK, I've just done it another way that makes life a lot easier to update things as and when the BBCodeParser gets updated, but it requires editing a path in the PHP files, currently I've done it using an relative path, which isn't a good thing for the end user yet. Basically, it would work for anyone who's running Vanilla from their domain eg or as they wouldn't have to change anything. I guess I need to add a variable or something like that to specify Vanilla's path???

    But the main thing is it works, two ways if you're willing to get your hands a little dirty.

    I'm pretty sure that the 2nd way is "the right way" to do things if I can solve the paths issue (help!), so
  • Options
    Hmm, Preview's not working either (smeg), although it does if I use absolute paths (this is a *REALLY* bad idea unless it can be done automatically, and might it nt still be a really bad idea from a security point on view?)...
  • Options
    edited November 2006
    When I was hacking around I found early on that Preview rendered the lists correctly after just a few simple changes. My disappointment when those changes didn't take in fully rendered pages drove me to solve it. So be careful using Preview as you test.. Hmm. My way broke nested lists. Argh. Definitely a hack. Now what did I do....
  • Options
    Gah. Try this: proposed BetterBBCode 1.1

    I poked around with it last summer, but only - half - partly - barely understand what's going on. I grabbed the "latest" from the Pear project and hacked away. Perhaps you code monkeys can sift through it with the above solutions you've figured out.

    Happy Thanksgiving!
  • Options
    I'd really like to see this fixed as well!
  • Options
    One other problem I've noticed--when Better BBCode changes URLs to links, the HTML sometimes gets split by a linebreak, putting /> on a separate line.
This discussion has been closed.