Skip to content

[Bug]: BrowserWindow.webPreferences.additionalArguments cannot contain a "\" (broken since v14.x.y) #32064

Description

@reZach

Preflight Checklist

Electron Version

14.0.0

What operating system are you using?

Windows

Operating System Version

Windows 10 Pro Version 20H2

What arch are you using?

x64

Last Known Working Electron version

13.3.0

Expected Behavior

I expect that I am able to pass in a string into additionalArguments that contains a "\". This functionality is no longer working in v14.0.0 (I also tested and see that it is broken in v16.0.0 as well).

Sample snippet (full repo is in "Additional Information" section)

let win = new BrowserWindow({
    width: 800,
    height: 600,
    title: "Title",
    webPreferences: {      
      additionalArguments: ["test"], // okay      
      additionalArguments: [`path:${app.getPath("userData")}`], // breaks
      preload: path.join(__dirname, "preload.js")      
    }
  });

Actual Behavior

I piggy-back off of additionalArguments in order to send a filepath to code that executes in the preload script.

I expect this to work

let win = new BrowserWindow({
    width: 800,
    height: 600,
    title: "Title",
    webPreferences: {      
      additionalArguments: [`path:${app.getPath("userData")}`],
      preload: path.join(__dirname, "preload.js")      
    }
  });

Testcase Gist URL

No response

Additional Information

Problem file in repo exists @app/electron/main.js

Steps to repro

git clone https://github.com/reZach/bad-upgrade.git
cd bad-upgrade
npm i
npm run dev

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions