• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Cannot reproduce xf-addon:build-release failure with invalid UTF8 characters in JS

Affected version


Well-known member
When using xf-addon:build-release with a js file in _files that has invalid unicode characters, the minifier will die.

The error message is just:
  Unable to parse JSON data: JSON_ERROR_SYNTAX - Syntax error, malformed JSON
Maybe this could be improved to point at the actual issue

Problem was in this code, probably due to the currency symbols
        id: "currency",
        is: function (s) {
            return /^[£$€?.]/.test(s);
        }, format: function (s) {
            return $.tablesorter.formatFloat(s.replace(new RegExp(/[£$€]/g), ""));
        }, type: "numeric"

Chris D

XenForo developer
Staff member
That exact code seems to compile correctly for me:
ts.addParser({id:"currency",is:function(a){return/^[\u00a3$\u20ac?.]/.test(a)},format:function(a){return $.tablesorter.formatFloat(a.replace(new RegExp(/[\u00a3$\u20ac]/g),""))},type:"numeric"});
Do you have any more examples that reproduce the issue?