Skip to content

Frontend: LiteSpeed's minifier cuts a regex in half and stops every combined script for visitors #2056

Closed

Description

@rpgmem

Problem

On the testing site, the verification page's device test (/valid/?ffc_device_check=1) stays at "Checking…" on every row for visitors who are not logged in, on phones and on desktop. A logged-in administrator sees it work.

Cause

LiteSpeed Cache minifies and combines scripts for guests. Its minifier, matthiasmullie/minify, mishandles a regex literal that ends in an escaped slash. When the literal is followed by ] or a line break, the minifier treats the closing slash as the start of a comment and drops the rest of the line. The rendered output on the testing site shows it:

  • source: ['LINE', /Line\//]
  • minified: ['LINE',/Line\];var BRANDS=…

The combined file then fails to parse ("Invalid regular expression: missing /"), so no script in it runs. The literal came in with #2053. Two more literals of the same shape exist (ffc-core.js, ffc-preflight.js); their current neighbours happen to survive minification.

Acceptance criteria

  • No regex literal in assets/js/ ends in an escaped slash. The three existing ones are rewritten to \/\d or \/{2}.
  • Every readable script in assets/js/ and libs/js/ runs through matthiasmullie/minify and still parses (verified once, by hand).
  • A guard test refuses the shape, with a canary and an independent recount of the scanned files.
  • CHANGELOG entry under Fixed.

Activity

  1. added a commit that references this issue on Oct 24, 2026
    0658079
  2. rpgmem commented on Oct 24, 2026

    @rpgmem
    OwnerAuthor

    Delivered in #2057 (merged to develop):

    • No regex literal in assets/js/ ends in an escaped slash any more. The three that did (ffc-device-check.js, ffc-core.js, ffc-preflight.js) now end in \/\d or \/{2}.
    • Every readable and minified script in assets/js/ and libs/js/ (232 files) was run through matthiasmullie/minify and still parses.
    • MinifierSafeRegexTest refuses the shape, with a canary and a scandir recount.
    • The CHANGELOG entry is under Fixed.

    On the testing site, purge the LiteSpeed JS cache after the deploy so the broken combined file is rebuilt.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions