Fixed Data is broken it first post contains tab / \XF::escapeString() does not handle JSON properly


Well-known member
Affected version
If the first post of a thread contains a tab, the resulting DiscussionForumPosting JSON data is broken as the tab is not converted to \t:

\XF:\Template\Templater::filterEscape() assigns the passed in type json to $escape, but \XF::escapeString() does not handle tabs:

case 'json':
    $value = strtr($value, [
        '\\' => '\\\\',
        '"' => '\\"',
        "\r" => '\r',
        "\n" => '\n',
        '/' => '\\/',
        '<!' => '\u003C!'
    return $value;

XF Bug Bot

XenForo bug fixer bot
Staff member
Thank you for reporting this issue. It has now been resolved and we are aiming to include it in a future XF release (2.1.3).

Change log:
When escaping JSON strings, ensure the tab character is converted to '\t'.
Any changes made as a result of this issue being resolved may not be rolled out here until later.