mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed runtime error Uncaught SyntaxError: yield is a reserved identifier when deadCodeInjection is enabled
This commit is contained in:
+5
-2
@@ -6,6 +6,8 @@ import * as ESTree from 'estree';
|
||||
import { TIdentifierNamesGeneratorFactory } from '../../types/container/generators/TIdentifierNamesGeneratorFactory';
|
||||
import { TStatement } from '../../types/node/TStatement';
|
||||
|
||||
import { StringSeparator } from '../../enums/StringSeparator';
|
||||
|
||||
import { ICustomCodeHelperFormatter } from '../../interfaces/custom-code-helpers/ICustomCodeHelperFormatter';
|
||||
import { IOptions } from '../../interfaces/options/IOptions';
|
||||
import { IRandomGenerator } from '../../interfaces/utils/IRandomGenerator';
|
||||
@@ -79,6 +81,7 @@ export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode
|
||||
protected getNodeStructure (): TStatement[] {
|
||||
const controllerIdentifierName: string = this.randomGenerator.getRandomString(6);
|
||||
const indexIdentifierName: string = this.randomGenerator.getRandomString(6);
|
||||
|
||||
const structure: ESTree.BlockStatement = NodeFactory.blockStatementNode([
|
||||
NodeFactory.variableDeclarationNode(
|
||||
[
|
||||
@@ -87,12 +90,12 @@ export class BlockStatementControlFlowFlatteningNode extends AbstractCustomNode
|
||||
NodeFactory.callExpressionNode(
|
||||
NodeFactory.memberExpressionNode(
|
||||
NodeFactory.literalNode(
|
||||
this.originalKeysIndexesInShuffledArray.join('|')
|
||||
this.originalKeysIndexesInShuffledArray.join(StringSeparator.VerticalLine)
|
||||
),
|
||||
NodeFactory.identifierNode('split')
|
||||
),
|
||||
[
|
||||
NodeFactory.literalNode('|')
|
||||
NodeFactory.literalNode(StringSeparator.VerticalLine)
|
||||
]
|
||||
)
|
||||
)
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
export enum StringSeparator {
|
||||
Dot = '.',
|
||||
Comma = ',',
|
||||
Dot = '.',
|
||||
VerticalLine = '|'
|
||||
}
|
||||
|
||||
@@ -49,5 +49,6 @@ export enum NodeType {
|
||||
UpdateExpression = 'UpdateExpression',
|
||||
VariableDeclaration = 'VariableDeclaration',
|
||||
VariableDeclarator = 'VariableDeclarator',
|
||||
WhileStatement = 'WhileStatement'
|
||||
WhileStatement = 'WhileStatement',
|
||||
YieldExpression = 'YieldExpression'
|
||||
}
|
||||
|
||||
@@ -104,6 +104,7 @@ export class DeadCodeInjectionTransformer extends AbstractNodeTransformer {
|
||||
|| NodeGuards.isBreakStatementNode(targetNode)
|
||||
|| NodeGuards.isContinueStatementNode(targetNode)
|
||||
|| NodeGuards.isAwaitExpressionNode(targetNode)
|
||||
|| NodeGuards.isYieldExpressionNode(targetNode)
|
||||
|| NodeGuards.isSuperNode(targetNode);
|
||||
}
|
||||
|
||||
|
||||
@@ -421,4 +421,12 @@ export class NodeGuards {
|
||||
public static isWhileStatementNode (node: ESTree.Node): node is ESTree.WhileStatement {
|
||||
return node.type === NodeType.WhileStatement;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {Node} node
|
||||
* @returns {boolean}
|
||||
*/
|
||||
public static isYieldExpressionNode (node: ESTree.Node): node is ESTree.YieldExpression {
|
||||
return node.type === NodeType.YieldExpression;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user