mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Merge pull request #461 from javascript-obfuscator/reserved-names-fix
Fixed `reservedNames` option
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
Change Log
|
||||
|
||||
v0.19.4
|
||||
---
|
||||
* Fixed `reservedNames` option
|
||||
|
||||
Thanks to our contributors!
|
||||
* [kida7](https://github.com/kida7)
|
||||
|
||||
v0.19.3
|
||||
---
|
||||
* The `splitStrings` option now correctly works with `transformObjectKeys` option
|
||||
|
||||
Vendored
+3
-3
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "javascript-obfuscator",
|
||||
"version": "0.19.3",
|
||||
"version": "0.19.4",
|
||||
"description": "JavaScript obfuscator",
|
||||
"keywords": [
|
||||
"obfuscator",
|
||||
|
||||
+1
-1
@@ -116,7 +116,7 @@ export class BaseIdentifierObfuscatingReplacer extends AbstractObfuscatingReplac
|
||||
* @returns {boolean}
|
||||
*/
|
||||
private isReservedName (name: string): boolean {
|
||||
if (!this.options.reservedNames || !this.options.reservedNames.length) {
|
||||
if (!this.options.reservedNames.length) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -304,7 +304,7 @@ describe('LiteralTransformer', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Variant #12: `reservedNames` option is enabled', () => {
|
||||
describe('Variant #12: `reservedStrings` option is enabled', () => {
|
||||
describe('Variant #1: base `reservedStrings` values', () => {
|
||||
describe('Variant #1: single reserved string value', () => {
|
||||
const stringLiteralRegExp1: RegExp = /const foo *= *'foo';/;
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
import { assert } from 'chai';
|
||||
|
||||
import { NO_ADDITIONAL_NODES_PRESET } from '../../../../../../../src/options/presets/NoCustomNodes';
|
||||
|
||||
import { readFileAsString } from '../../../../../../helpers/readFileAsString';
|
||||
|
||||
import { JavaScriptObfuscator } from '../../../../../../../src/JavaScriptObfuscatorFacade';
|
||||
|
||||
describe('BaseIdentifierObfuscatingReplacer', () => {
|
||||
describe('Base rule', () => {
|
||||
describe('Variant #1: default behaviour', () => {
|
||||
let obfuscatedCode: string;
|
||||
|
||||
before(() => {
|
||||
const code: string = readFileAsString(__dirname + '/fixtures/simple-input.js');
|
||||
|
||||
obfuscatedCode = JavaScriptObfuscator.obfuscate(
|
||||
code,
|
||||
{
|
||||
...NO_ADDITIONAL_NODES_PRESET,
|
||||
reservedNames: ['[abc|ghi]']
|
||||
}
|
||||
).getObfuscatedCode();
|
||||
});
|
||||
|
||||
it('Should keep reserved names without transformations when `reservedNames` option is enabled', () => {
|
||||
assert.match(
|
||||
obfuscatedCode,
|
||||
/var *abc *= *0x1; *var *_0x([a-f0-9]){4,6} *= *0x2; *var *ghi *= *0x3;/
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
(function () {
|
||||
var abc = 1;
|
||||
var def = 2;
|
||||
var ghi = 3;
|
||||
})();
|
||||
Reference in New Issue
Block a user