MyBB Community Forums

Full Version: Are $mybb property arrays sanitized for use in templates?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I assume the answer is yes, but these things are important to get right

If I put $mybb->user['username'] in some template code, it will substitute that with the logged-in user's username.

What sanitization is done behind the scenes before that is inserted into the page HTML? The kind of thing I'm thinking of doing is creating a form section on a page, where the username would be the value of a hidden form input. I obviously want to work safely, avoiding any risks of injection or data exposure - and certain characters in usernames (such as ', ", or >) would obviously be undesireable.

Am I correct to assume that this kind of thing has already been taken care of by the MyBB engine by the time the $mybb->user array is formed?
Yes, you can use {$mybb->user['username']} in the templates.
Since you're concerned, check this: https://github.com/mybb/mybb/blob/featur...p#L75-L123