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

Kirby

Well-known member
Affected version
2.1.2
If the first post of a thread contains a tab, the resulting schema.org 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:

PHP:
case 'json':
    $value = strtr($value, [
        '\\' => '\\\\',
        '"' => '\\"',
        "\r" => '\r',
        "\n" => '\n',
        '/' => '\\/',
        '<!' => '\u003C!'
    ]);
    return $value;
 
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.
 
Back
Top Bottom