Skip to content

Crash on invalid Regex in Window Properties (SyntaxError: nothing to repeat) #1136

@bryeng

Description

@bryeng

Description:
Having entered an invalid regular expression in the "Window Properties" settings (e.g., a typo like /*Slack/), the extension crashed and failed to reload, and locked me out of the extension until the setting was cleared or corrected.

Having access to settings via Extension Manager meant a fix/workaround was easy to apply. The slightly trickier part is to connect the dots. In my case the edit was recent enough to make a smell.

Steps to Reproduce:

  1. Open PaperWM Settings -> Window Properties.
  2. Add a new property.
  3. In wm_class or title, enter an invalid regex string like /*Test/ (where * is the first character inside the slashes).
  4. The extension will crash with SyntaxError: nothing to repeat.

Stack Trace / Error:

1 SyntaxError: nothing to repeat @ file:///.../paperwm@paperwm.github.com/settings.js:468:30

Suggested Fix:
In settings.js, the new RegExp() calls should be wrapped in try...catch blocks to handle user input errors gracefully.

Example Patch:

// settings.js
try {
     prop.wm_class = new RegExp(inner, flags);
} catch (e) {
    console.warn(`PaperWM: Invalid regex in user settings for wm_class: ${prop.wm_class}`, e);
}

System information:

Distribution: Fedora Linux 43 (Workstation Edition)
GNOME Shell: 49.3
Display server: Wayland
PaperWM version: 49.0.0
Enabled extensions:
- launch-new-instance@gnome-shell-extensions.gcampax.github.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugUndesirable behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions