yii2mod / yii2-comments

Comments module for Yii2
MIT License
159 stars 64 forks source link

RuntimeException Unclosed string #84

Closed Fatal-Errol closed 6 years ago

Fatal-Errol commented 6 years ago

The code below

function r(a) {
    return /[\\\"<>\.;]/.exec(a) != null &&
        typeof encodeURIComponent != v ? encodeURIComponent(a) : a
}

and this one:

/\?/.test(b) && (b = b.split("?")[1]);

will throw an error:

An Error occurred while handling another error: exception 'RuntimeException' with message 'Unclosed string at position: 1317283' in .../vendor/tedivm/jshrink/src/JShrink/Minifier.php:483

The first one is caused by the "unclosed" quote in the regex, not sure about the second one. A temporary fix that I did was to add a comment so that the parser ignores the issue:

function r(a) {
    return /[\\\"<>\.;]/.exec(a) /*"*/ != null &&
        typeof encodeURIComponent != v ? encodeURIComponent(a) : a
}

and

/\?/.test(b) /*this is a temp fix for the compressor. removing this comment will cause an error*/
                    && (b = b.split("?")[1]);

This happens when I add FusionCharts.js in my site so other third party libs might cause this as well.

Thanks for the help.