mirror of
https://github.com/javascript-obfuscator/javascript-obfuscator
synced 2026-08-09 12:42:29 +00:00
Fixed infinite loop / stack overflow when reservedNames patterns match all generated identifier names (#1390)
This commit is contained in:
+22
@@ -121,4 +121,26 @@ describe('HexadecimalIdentifierNamesGenerator', () => {
|
||||
assert.notEqual(hexadecimalIdentifierName1, hexadecimalIdentifierName2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('`reservedNames` that match all generated names', () => {
|
||||
let testFunc: () => void;
|
||||
|
||||
before(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {
|
||||
reservedNames: ['^(?!renameMeOnly$)']
|
||||
});
|
||||
const identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.HexadecimalIdentifierNamesGenerator
|
||||
);
|
||||
|
||||
testFunc = () => identifierNamesGenerator.generateNext();
|
||||
});
|
||||
|
||||
it('should throw an error when all generated names match reservedNames', () => {
|
||||
assert.throws(testFunc, 'Unable to generate a valid identifier name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+22
@@ -217,4 +217,26 @@ describe('MangledShuffledIdentifierNamesGenerator', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('`reservedNames` that match all generated names', () => {
|
||||
let testFunc: () => void;
|
||||
|
||||
beforeEach(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {
|
||||
reservedNames: ['^(?!renameMeOnly$)']
|
||||
});
|
||||
const identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.MangledShuffledIdentifierNamesGenerator
|
||||
);
|
||||
|
||||
testFunc = () => identifierNamesGenerator.generateNext();
|
||||
});
|
||||
|
||||
it('should throw an error when all generated names match reservedNames', () => {
|
||||
assert.throws(testFunc, 'Unable to generate a valid identifier name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+22
@@ -342,4 +342,26 @@ describe('MangledIdentifierNamesGenerator', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('`reservedNames` that match all generated names', () => {
|
||||
let testFunc: () => void;
|
||||
|
||||
beforeEach(() => {
|
||||
const inversifyContainerFacade: IInversifyContainerFacade = new InversifyContainerFacade();
|
||||
|
||||
inversifyContainerFacade.load('', '', {
|
||||
reservedNames: ['^(?!renameMeOnly$)']
|
||||
});
|
||||
const identifierNamesGenerator = inversifyContainerFacade.getNamed<IIdentifierNamesGenerator>(
|
||||
ServiceIdentifiers.IIdentifierNamesGenerator,
|
||||
IdentifierNamesGenerator.MangledIdentifierNamesGenerator
|
||||
);
|
||||
|
||||
testFunc = () => identifierNamesGenerator.generateNext();
|
||||
});
|
||||
|
||||
it('should throw an error when all generated names match reservedNames', () => {
|
||||
assert.throws(testFunc, 'Unable to generate a valid identifier name');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user