Forums

bugs in balanceTags? (5 posts)

  1. Matt Mullenweg
    Troublemaker
    Posted 8 years ago #

    I have had this happen to me before too. We need to set up some test cases so the bug can be tracked down.

  2. Anonymous
    Unregistered
    Posted 8 years ago #

    Just posted a bug about this yesterday in the SF.net tracker, test case included:
    http://sourceforge.net/tracker/index.php?func=detail&aid=962432&group_id=51422&atid=463233
    This the test case:
    <b><i>tag soup!</b></i>test
    link

    And the result I get:
    <b><i>tag soup!</i></b>"http://www.google.com">test link

  3. davidchait
    Member
    Posted 8 years ago #

    I fixed my code to handle comments properly -- just needed to still build up the $tag after detecting it initially blank (to get the contents out of [2] of the regexp). That cleans up the stack handling a lot, probably speeds up the code for people with a lot of inline comments.
    My case was something like
    text [more]
    [comment]
    [comment]
    text
    [ul]
    [li][strong]text[/strong]text[/li]
    ... a bunch of times
    .. then one line missing the [/li]
    .. few more closed properly
    [/ul]
    text
    [comment]
    this text gets chopped off a bit at the start of the line.
    =======
    -d

  4. Anonymous
    Unregistered
    Posted 8 years ago #

    if you fixed it, could you share your code? :) Perhaps the core developers are interested in those fixes... and I'm also interested in using this very cool function in one of my little apps.

  5. davidchait
    Member
    Posted 8 years ago #

    This is obviously just a portion of the balanceTags function, and I'm working off an earlier (non-1.2) codebase -- though the code is likely near-identical...

    } else { // Begin Tag
    $tag = strtolower($regex[1]);
    $attributes = $regex[2];
    if (empty($tag)) {
    // echo "re0: $regex[0], re1: $regex[1], re2: $regex[2]\n<br>";
    } else {
    // echo "TAG: $tag\n<br>";
    // Tag Cleaning
    // Push if not img or br or hr
    if($tag != 'br' && $tag != 'img' && $tag != 'hr') {
    $stacksize = array_push ($tagstack, $tag);
    }
    // Attributes
    // $attributes = $regex[2];
    if($attributes) {
    // fix to avoid CSS defacements
    if ($is_comment) {
    $attributes = str_replace('style=', 'title=', $attributes);
    $attributes = str_replace('class=', 'title=', $attributes);
    $attributes = str_replace('id=', 'title=', $attributes);
    }
    $attributes = ' '.$attributes;
    }
    }
    // always build up new $tag, so we capture comments back...
    $tag = '<'.$tag.$attributes.'>';
    }

    -d

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.