SimpleMachines / SMF

Simple Machines Forum — SMF in short — is free and open-source community forum software, delivering professional grade features in a package that allows you to set up your own online community within minutes!
https://www.simplemachines.org/
Other
583 stars 250 forks source link

List Code BBC bug #3106

Closed jdarwood007 closed 7 years ago

jdarwood007 commented 8 years ago
[list][li]Test[/li][li]More[code]Some COde[/code][/li][/list]

The above BBC breaks and does not product a proper output and the parser incorrectly handles ending the list. The code bbc is very special so it could be difficult to handle properly. The quote bbc works fine though.

joshuaadickerson commented 8 years ago

Result:

<ul class="bbc_list"><li>Test</li></ul>[li]More[/li][/list]<div class="codeheader">Code: <a href="javascript:void(0);" onclick="return smfSelectText(this);" class="codeoperation">[Select]</a></div><code class="bbc_code">Some COde</code><ul class="bbc_list">[/li]</ul>
joshuaadickerson commented 8 years ago

It happens in the preparser. This is the result:

[list][li]Test[/li][/list][li]More[/li][/list][code]Some COde[/code][list][/li][/list]

I think it would require completely changing the preparser. It happens because the regex that checks if the lists/tables are closed are done on each element of an array. That array is created by preg_split('~(\[/code\]|\[code(?:=[^\]]+)?\])~i' which splits the message by code blocks. It will also break tables with code blocks inside of it as well for the same reason.

Kindred-999 commented 8 years ago

Or we could just declare that code blocks do not belong inside lists or tables...

In all honesty, I don't think that they do...

Bloc67 commented 8 years ago

I agreed FWIW, code should exist only outside of tables and lists. The parser should just ignore it. (or not parse it as anything other than plain text)

Sesquipedalian commented 8 years ago

By golly, I think I've fixed this one. :) #3572