notevil icon indicating copy to clipboard operation
notevil copied to clipboard

Unexpected expression: 'WithStatement'

Open ragoutje opened this issue 5 years ago • 2 comments

I'm currently trying to implement notevil 1.1.0 into Vue to create a Vue 2.6-csp build. However I'm running into the fact that with statements are used in Vue and notevil throws an error for these statements: https://github.com/mmckegg/notevil/blob/master/index.js#L368

In Vue I am able to find the following code which probably triggers this (https://github.com/vuejs/vue/blob/2.6/src/compiler/codegen/index.js#L49):

with(this){return ${code}}

And somewhere in the code following where that line is executed by:

return new Function(code)

Which I have tried to replace with:

const fn = notevil.Function(code);
        return function() {
            return fn.call(this);
        };

Where I have tried to inject the this property to be used in the with(this) expression.

The result is a Unexpected expression: 'WithStatement' error in my console.

Is it possible to add the ability to parse with statements? Or does anyone have suggestions on how to work around the with(this) expressions?

ragoutje avatar Apr 23 '19 12:04 ragoutje

This is the issue I opened at the Vue repo: https://github.com/vuejs/vue/issues/9895

ragoutje avatar Apr 23 '19 12:04 ragoutje

I would accept a pull request to add support for with statements, but I do not have the time to add this myself.

mmckegg avatar Aug 29 '19 06:08 mmckegg