Skip to content

Fixed splitStrings and stringArray breaking a quoted constructor class key - #1466

Merged
sanex3339 merged 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix-quoted-constructor-class-key-1464
Nov 1, 2026
Merged

sanex3339 merged 1 commit into
javascript-obfuscator:masterfrom
cycsmail:fix-quoted-constructor-class-key-1464

Conversation

@cycsmail

Copy link
Copy Markdown
Contributor

class A { 'constructor'() {} } is a real constructor, but with splitStrings or stringArray the key got rewritten in place into 'co'+'ns'+... or a string array call while staying a non-computed key, so the output didn't parse. ClassFieldTransformer already leaves constructor as a plain literal on purpose (a computed key would stop being the constructor), the shared isProhibitedLiteralNode guard just didn't know about class keys. Extended it to non-computed MethodDefinition/PropertyDefinition keys, the same rule it already applies to object Property keys. Other quoted keys are made computed before the string transforms run, so they are still split/arrayed as before.

The two existing stringArray expectations in ClassFieldTransformer.spec.ts listed constructor in the string array, which was the bug, so they now match the identifier-key variant and bar moves from index 0x2 to 0x1. New unit cases for MethodDefinition/PropertyDefinition keys and a splitStrings variant on the literal-key fixture fail on master.

Fixed #1464

@sanex3339

Copy link
Copy Markdown
Member

Thank you!

@sanex3339
sanex3339 merged commit bda26b9 into javascript-obfuscator:master Nov 1, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Quoted class constructor "constructor"() {} produces invalid code with splitStrings or stringArray

2 participants