mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
More complex object keys transformation + some string literal transformations refactoring
This commit is contained in:
@@ -12,6 +12,7 @@ import { IStringArrayStorageItemData } from '../../interfaces/storages/string-ar
|
||||
|
||||
import { NodeGuards } from '../../node/NodeGuards';
|
||||
import { NodeMetadata } from '../../node/NodeMetadata';
|
||||
import { NodeLiteralUtils } from '../../node/NodeLiteralUtils';
|
||||
|
||||
/**
|
||||
* Adds values of literal nodes to the string array storage
|
||||
@@ -67,7 +68,11 @@ export class StringArrayStorageAnalyzer implements IStringArrayStorageAnalyzer {
|
||||
}
|
||||
|
||||
estraverse.traverse(astTree, {
|
||||
enter: (node: ESTree.Node): estraverse.VisitorOption | void => {
|
||||
enter: (node: ESTree.Node, parentNode: ESTree.Node | null): estraverse.VisitorOption | void => {
|
||||
if (!parentNode) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NodeMetadata.isIgnoredNode(node)) {
|
||||
return estraverse.VisitorOption.Skip;
|
||||
}
|
||||
@@ -76,7 +81,7 @@ export class StringArrayStorageAnalyzer implements IStringArrayStorageAnalyzer {
|
||||
return;
|
||||
}
|
||||
|
||||
this.analyzeLiteralNode(node);
|
||||
this.analyzeLiteralNode(node, parentNode);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -91,12 +96,17 @@ export class StringArrayStorageAnalyzer implements IStringArrayStorageAnalyzer {
|
||||
|
||||
/**
|
||||
* @param {Literal} literalNode
|
||||
* @param {Node} parentNode
|
||||
*/
|
||||
private analyzeLiteralNode (literalNode: ESTree.Literal): void {
|
||||
private analyzeLiteralNode (literalNode: ESTree.Literal, parentNode: ESTree.Node): void {
|
||||
if (typeof literalNode.value !== 'string') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (NodeLiteralUtils.isProhibitedLiteralNode(literalNode, parentNode)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.shouldAddValueToStringArray(literalNode.value)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user