AssignmentRestProperty does not work without AssignmentPropertyList
See original GitHub issueI’ve created an issue as a bug as partial ECMAScript 2019 support is declared on web site.
Expected Behavior
const { ...fields } = req.body;
should be obfuscated
Current Behavior
For now seems like many features of ECMAScript 2018 is supported except at least one when AssignmentRestProperty alone is used at the LeftHandSideExpression of destructuring assignment.
Example:
const { ...fields } = req.body;
Runing javascript-obfuscator against that string gives:
[javascript-obfuscator-cli] Error in file: playground/test.js...
Although it works well when AssignmentPropertyList is present before the rest.
This string will not cause an error:
const { foo, ...fields } = req.body;
Steps to Reproduce
- create test.js file with a content from example below
- run javascript-obfuscator against it
javascript-obfuscator ./test.js --output ./
- experience an error
Your Environment
- Obfuscator version used: 0.28.1
- Node version used: 12.13.1
Stack trace
/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:2226
if (property.value.type !== Syntax.Identifier) {
^
TypeError: Cannot read property 'type' of undefined
at CodeGenerator.ObjectPattern (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:2226:36)
at CodeGenerator.generateExpression (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:2469:28)
at CodeGenerator.VariableDeclarator (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:1438:26)
at CodeGenerator.generateStatement (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:2482:33)
at block (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:1465:38)
at CodeGenerator.VariableDeclaration (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:1483:17)
at CodeGenerator.generateStatement (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:2482:33)
at /Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:1075:51
at withIndent (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:576:9)
at CodeGenerator.BlockStatement (/Users/lonedone/.nvm/versions/node/v12.13.1/lib/node_modules/javascript-obfuscator/node_modules/escodegen/escodegen.js:1025:13)
Minimal working example that will help to reproduce issue
const req = {
foo: 'foo_str',
bar: 'bar_str',
};
const { ...fields } = req;
console.log(fields);
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (4 by maintainers)
Top Results From Across the Web
c# property setter not called when assiging the same value
My problem is that when I assign the property ggFileName with the same value it already contains, nothing happens. The setter is not...
Read more >Using Properties - C# Programming Guide - Microsoft Learn
A property without a set accessor is considered read-only. A property without a get accessor is considered write-only.
Read more >CSSStyleDeclaration.setProperty() - Web APIs | MDN
The CSSStyleDeclaration.setProperty() method interface sets a new value for a property on a CSS style declaration object.
Read more >11 Properties: assignment vs. definition - Exploring JS
Invoking setters: If there is an own or inherited setter for .prop , assignment invokes that setter. Creating properties: If there is no...
Read more >Properties - Manual - PHP
Note: A property declared without a Visibility modifier will be declared as ... Modifications are not necessarily plain assignments, all of the following ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I created PR with fix some time ago. Please ping this PR https://github.com/estools/escodegen/pull/408
Fixed and released as
0.28.5