Skip to content

URI malformed with Base64 string-array encoding and surrogate-range literal #1431

Description

@JasonHZS

Expected Behavior

Obfuscation completes for valid JavaScript that contains a string literal with surrogate code units used in a regex range.

Current Behavior

Base64 string-array encoding throws URIError: URI malformed. This reproduces in v5.4.1 and appears related to the previously fixed #530.

Steps to Reproduce

  1. Install javascript-obfuscator@5.4.1.
  2. Run the minimal example below.

JavaScript Obfuscator Edition

  • JavaScript Obfuscator Open Source

Your Environment

  • Obfuscator version used: 5.4.1
  • Node version used: v23.7.0

Stack trace

URIError: URI malformed
    at encodeURIComponent (<anonymous>)

Minimal working example that will help to reproduce issue

const JavaScriptObfuscator = require("javascript-obfuscator");

JavaScriptObfuscator.obfuscate(
  String.raw`const controlSymbolRegexString = "\\\\[^\uD800-\uDFFF]";`,
  {
    stringArray: true,
    stringArrayEncoding: ["base64"],
    stringArrayThreshold: 1,
    splitStrings: true,
    splitStringsChunkLength: 5,
    seed: 1,
  },
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions