Has anyone else noticed problems with unclosed tags when using bbcode with flatforums? When they pop up they seem to pretty much kill formatting on pages.

Comments

naudefj’s picture

Can you please provide a test case and maybe a screenshot to illustrate the problem?

rkn-dupe’s picture

Thanks for the reply, yes sorry i wasnt very detailed before.

To show what i am talking about please see:
http://libcom.org/forums/feedback-and-content/test-thread-unclosed-quote...

So when the bbcode is meant to close the tags - it looks almost like it is closing it - but in the wrong place? Perhaps this is something to do with float properties in flatforum?

naudefj’s picture

BBcode doesn't know where to add the closing tags, so it just appends them to the text:

  preg_match_all('/\[quote/i', $body, $matches);
  $opentags = count($matches['0']);
  preg_match_all('/\[\/quote\]/i', $body, $matches);
  $unclosed = $opentags - count($matches['0']);
  for ($i = 0; $i < $unclosed; $i++)
     $body .= '[/quote]';
catch’s picture

The worst thing seems to be "unopened" closing tags - so [/quote] or [/quote][/quote] - which don't seem to be automatically opened in the same way open tags are closed.

naudefj’s picture

Badly formatted text will always be problematic - you never know if the user would like to see the tags rendered or not.

I'm not sure if it's worth while persuing this further.

catch’s picture

Could there be an addition to this code to add open tags at the beginning of posts where there are extra closed tags?

preg_match_all('/\[quote/i', $body, $matches);
  $opentags = count($matches['0']);
  preg_match_all('/\[\/quote\]/i', $body, $matches);
  $unclosed = $opentags - count($matches['0']);
  for ($i = 0; $i < $unclosed; $i++)
     $body .= '[/quote]';
naudefj’s picture

Status:Active» Closed (won't fix)

Personally, I don't think we should: It will create weird looking output and users will not necessarily know it's cased by invalid quoting. Also, if we do it for quotes, we will have to do it for all the other tags as well (too CPU intensive).