Partial fix Tiny errors in BB code markup can turn your post into a mess šŸ™ƒ

Steffen

Well-known member
Affected version
2.0.12
Original bug report (or "complaint") here in german: https://www.computerbase.de/forum/t...mputerbase-forum-ist-da.1801339/post-22008449

I've tried to come up with a more generic test-case. Consider the following BB code:

Code:
- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

This is what it looks like when you toggle the editor mode or submit the post:

190017

Some users prefer to use the plaintext editor when writing posts. In this case, typos can affect BB code tags. Let's assume that the user mistyped the first closing "URL" BB code as [/UL] (an "R" is missing):

Code:
- [URL='https://xenforo.com/']Link[/UL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text
- [URL='https://xenforo.com/']Link[/URL] Text

Text
Text

This is what it looks like when you now submit the post (or toggle the editor mode):

190018

And this is the BB code when you toggle the editor mode back:

190019

A tiny typo in the first line has caused major parts of the message to be changed. Line breaks have been removed and plaintext has been turned into links. It would require a lot of effort from the user to fix this well-meant but unfortunately badly-behaving auto-correction of broken BB code. If XenForo had not touched the BB Code, then all the user would have to do is add the missing "R".

I have not dug deeper into what's actually going on that causes this issue. Maybe it has something to do with auto-closing BB code tags that aren't closed explicitly. I fear that fixing this issue could require more involved changes to the XenForo codebase. It would therefore probably be unreasonable to expect a short-term fix. But I wanted to bring this issue to your attention nevertheless. :)
 
Last edited:
I'm going to call this a partial fix, as I have made a change that resolves some of the worst issues shown by your example (which were particular to the URL tag). There are some potential issues that can happen with this when you toggle the RTE on and off, though that's fairly unavoidable as we need to do significant manipulations to the BB code for the RTE HTML (and it needs to be valid).

The biggest issues caused by the mistake shown here relate to triggering nested <a> tags, which just isn't valid. I have added parse-time validation code for URL and email tags that prevent them from being nested. The inner tag (which isn't valid in that context and wouldn't be producible in an RTE) will simply be rendered as text. This essentially fixes the issues that trigger line break removal. (Though the example does show a quirk with Markdown conversion, but I don't think that's something we'd be looking to change at this time.)

Conceptually the issue does still exist with other tags, though they don't tend to cause as significant issues and in many cases, the only change to the message is the tag "properly" being closed at the end. I wouldn't expect any further changes in how we process BB code like this, though we may handle case-by-case issues if they cause particular oddities.
 
Thank you for the fix and the explanation! :)

Will this fix make it into XenForo 2.0.13 or will it only be part of XenForo 2.1?
 
Back
Top Bottom