You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Escaped "use\x20strict" in directive prologue is emitted as 'use strict' #1474
Obfuscating a script or function whose directive prologue contains an escaped "use\x20strict" string should not turn it into an unescaped 'use strict' directive, preserving non-strict mode semantics (printing false in the example below).
Current Behavior
javascript-obfuscator emits function f(){'use strict';return this===undefined;}console['log'](f());, which turns the escaped string in the directive prologue into an active 'use strict' directive and changes this === undefined inside f() from false to true.
Because directive ExpressionStatement nodes are skipped during literal transformation, their string literals do not receive the raw verbatim property and the code generator falls back to printing the cooked string value.
Steps to Reproduce
Pass a function containing "use\x20strict"; in its directive prologue to JavaScriptObfuscator.obfuscate with { stringArray: false }.
Execute the obfuscated code and compare its output with the original code.
JavaScript Obfuscator Edition
JavaScript Obfuscator Open Source
Your Environment
Obfuscator version used: 5.10.0
Node version used: v24.14.1
Stack trace
N/A (wrong runtime behavior, no exception thrown)
Minimal working example that will help to reproduce issue
constJavaScriptObfuscator=require('javascript-obfuscator');constcode='function f() { "use\\x20strict"; return this === undefined; }\nconsole.log(f());';constobfuscated=JavaScriptObfuscator.obfuscate(code,{stringArray: false}).getObfuscatedCode();console.log(obfuscated);eval(obfuscated);
Activity
Fixes for 1471-1477