Wrapping [indent] around [quote] does not behave sanely when toggling bb-code mode

Xon

Well-known member
Affected version
2.2.7 Patch 1
If you toggle bb-code mode on/off, the following raw bb-code;

[indent]
[quote="Someone"]
Line1
Line2
Line3
[/quote]
[/indent]


Is turned into

[INDENT][/INDENT]
[QUOTE="Someone"]
Line1
[INDENT]Line2[/INDENT]
[INDENT]Line3[/INDENT]
[/QUOTE]
 
A similar bug appears with [code] bb-code, and probably anything else which is multiple lines;


[indent]
[code]
1
2
3
[/code]
[/indent]


Turns into;

[INDENT][/INDENT]
[INDENT][code][/INDENT]
[INDENT]1[/INDENT]
[INDENT]2[/INDENT]
[INDENT]3[/INDENT]
[INDENT][/code][/INDENT]
[INDENT][/INDENT]


Wrapping the indent tag around the code block then causes massive round-trip issues as it continuously adds more indent tags.

This appears to affect any "block" bb-code in XenForo which can have HTML formatting wrapped around what is expected to be bb-code.

List;

[B]1
[list]
[*]2
[/list]
3
[/B]


Becomes;

[B]1
[/B]
[LIST]
[*][B][LIST]
[*]2
[/LIST][/B]
[/LIST]
[B]3[/B]
 
Last edited:
The 'to-html' function returns;
HTML:
<p><strong>1</strong></p>
<p>
    <strong>
        <ul>
            <li data-xf-list-type=\"ul\">2</li>
        </ul>
        <p>3
            </strong>
        </p>
<p><strong></strong></p>
But the editor renders it as;
HTML:
<p><strong>1</strong></p>
<p><strong>&nbsp;</strong></p>
<ul>
    <li>
        <strong>
        <ul>
           <li data-xf-list-type="ul">2</li>
        </ul>
        </strong>
    </li>
</ul>
<p><strong>3</strong></p>
<p><br></p>

This is the bad HTML which appears to be triggering the issue;
HTML:
<p><strong> ... <p>3</strong></p>

the strong tag is overlapping the <p> and the closing tag is missing
 
Last edited:
The root of the problem is two things;
  • <p> isn't permitted to have a number of things as it's children (EditorHtml::renderTagIndent and EditorHtml::renderTagHeading), it should use <div>
  • \XF\Html\Renderer\BbCode doesn't correctly undo the editor injecting a indent per-line, resulting in indent's mixed into existing line content when it shouldn't be.
 
Indent code block handling isn't vaguely right still.

Quote handling is better, input:
[indent]
[quote="Someone"]
Line1
Line2
Line3
[/quote]
[/indent]

Output on toggling:

[INDENT][/INDENT]
[QUOTE="Someone"]
Line1
[INDENT]Line2[/INDENT]
[INDENT]Line3[/INDENT]
[/QUOTE]

Line1 isn't indented, and the preview shows the quote itself being indented which doesn't match toggling bb-code mode on/off.


List fails in even weirder ways:

[B]1
[list]
[*]2
[/list]
3
[/B]

Toggled gives:

[B]1
[/B]
[LIST]
[*][B][LIST]
[*]2
[/LIST][/B]
[/LIST]
[B]3[/B]
 
Back
Top Bottom