MyBB Community Forums

Full Version: Issues of the code actually generate BBcode html
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I have two issues in adding mycode

Regular Expression:
\[hide=(.*?)\](.*?)\[/hide\]

Replacement
<dl class="codebox"><dt><a href="javascript:void(0);" onclick="var el = this.parentNode.parentNode.getElementsByTagName('dd')[0]; var v = el.style.display != 'none'; el.style.display = v ? 'none' : 'block'; this.innerHTML = (v ? '[+]' : '[−]') + '$1'; ">[+] $1</a></dt><dd style="display: none;">$2</dd></dl>

(1) It converted $1 to upper case string
(2) It added extra "<br/>" at the end of the html block.

Is there any danger in that piece of the code without convert $1 to upper case, and without adding extra '<br/>' at the end?
I'm trying to do something about it... Any advises? Thanks
MyCodes don't convert upper/lowercase, so I don't understand why that would be happening.

The <br> is probably a regular newline after the MyCode. For every newline, MyBB puts a <br>. Is there a <br> even if you use [hide=x]y[/hide] in mid sentence without newlines?

Maybe the newlines would go away if you include them in your match, without including them in the replacement, e.g.
\n*\[hide=(.*?)\]\n*(.*?)\n*\[/hide\]\n*
(remove the \n* where you don't want newlines removed).

You should be aware that inserting $1 in the JavaScript part might enable someone to abuse JavaScript somehow, e.g. what happens when you use [hide='+alert('hello')+']...[/hide]?