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.

Links and <br /> tags with Better BB Code 1.0

Hello.

I have a problem with the Better BBCode extension v.1.0. If I have a line break just after the URL and some text after that, the extenstion takes the "br" part with it.
So, when I type:

"http://www.url.com
some text below the url"

It comes out as:

image

Other extensions that I have installed are: Discussion filters 1.0, Extended Application Form 1.0, New Applicants 1, Quotations 1.5, Role History 1.0, Saved Searches 2.0, Text Mode Switch 1.0, Transmogrifier 1.1, Who's Online 1.1.

Note that the "Format comments as BBcode" is chosen.

Thanks in advance.

Comments

  • make a space after the url
  • That's the easy way. :) I can't tell every one of my users to make a space.
  • lamentlament
    edited July 2006
    I can't tell every one of my users to make a space.

    sure you can. or make a FAQ sticky post.
  • edited July 2006
    Technically, I can, but why would I want to bother doing that? It's easier just to fix this. I think that the parsers for BBcode on every forum are almost identical, so how come I don't get this when using IPB or phpBb for example?
  • edited July 2006
    EDIT: The offending code is here:

    $pattern = array( "!(^|\s|\()((((http(s?)|ftp)://)|www)[-a-z0-9.]+\.[a-z]{2,4}[^\s()]*)!i", "!".$oe."url(".$ce."|\s.*".$ce.")(.*)".$oe."/url".$ce."!iU"); $replace = array( "\\1".$o."url".$c."\\2".$o."/url".$c, $o."url=\\2\\1\\2".$o."/url".$c); $this->_preparsed = preg_replace($pattern, $replace, $this->_preparsed);

    in the preparse function of BBCodeParser.php. To stop the auto replacement, change it to this:

    $pattern = array("!".$oe."url(".$ce."|\s.*".$ce.")(.*)".$oe."/url".$ce."!iU"); $replace = array($o."url=\\2\\1\\2".$o."/url".$c); $this->_preparsed = preg_replace($pattern, $replace, $this->_preparsed);
  • Well, that's one solution, but I'd like to keep the auto replacement. I just want to fix the <br /> problem.
  • edited May 2008
    My apologies, guys... I've discovered this is my exact problem as well.

    Any one know of the <br/> culprit in the code?

    edit/update: Some more issues...The parser is tripping up (BBCodeParser.php) in these scenarios as well:
    - link will not be parsed if it is not the FIRST piece of content in the comment body (very odd issue, quite buggy...seems to be very touchy with manually entered spaces before/after it????)
    - only one line will be parsed, entering a link on more than one line will only result in the first line being successfully parsed
    - "shorthand" URLs (wwithout the "http://") simply won't work at all. They'll be parsed if they meet the above prerequisites, but the parser hooks the shorthand URL on the end of the forum URL resulting in a link to http://www.domain.com/forum/www.ShortHandURL.com

    Can anyone head me in the right direction with the parser? Do these problems lie in the links portion of the BB parser?
    //Links $pattern = array( "!(^|\s|\()((((http(s?)|ftp)://)|www)[-a-z0-9.]+\.[a-z]{2,4}[^\s()]*)!i", "!".$oe."url(".$ce."|\s.*".$ce.")(.*)".$oe."/url".$ce."!iU"); $replace = array( "\\1".$o."url".$c."\\2".$o."/url".$c, $o."url=\\2\\1\\2".$o."/url".$c); $this->_preparsed = preg_replace($pattern, $replace, $this->_preparsed);
  • This strikes me as something others would have encountered before... Anyone know of a fix to get the links working correctly?
  • Not off hand... If there are some situations where an extra space or removing a space fix things, it might be easier to massage the text before it passes through... is there a reason that you need to use Better BBCode instead of BBCode Parser?
  • edited May 2008
    No I don't believe I do... Don't they both use the same BBCode parser php file though? What do you mean by massaging the text as well? edit: Installed and switched to BBCode Parser... Thanks for the suggestion, it does seem to be handling auto linking better. Still some little, rather insignificant, display issues with ignoring manual user line breaks in comments when dealing with URLs or image and text, but I can cope. Thanks!
This discussion has been closed.