Backtrack limit exhausted in regular expression

Created on 5 November 2024, 10 days ago

Problem/Motivation

We currently have a client that has pages that contain lots of data that needs to be pushed to JavaScript. When the minifyhtml module is enabled, this leads to an error when minifying the script tags containing the DrupalSettings.
Backtrack limit exhausted in regular expression "/\s*<script(\b[^>]*?>[\s\S]*?<\/script>)\s*/i" (code: 2).

Steps to reproduce

Enable the module
Create a page with a large DrupalSettings object.
Observe the Backtrack limit exhausted in regular expression error.

Proposed resolution

We can do the following things:

  1. Prevent minifying large string in general. This would not need any configuration.
  2. Allow settings to disable parts of the minification.

Since the module now requires very little configuration, I guess option 1 would be the easiest solution, and still allows minifying of smaller script tags.

Remaining tasks

Write a patch
Review
Commit

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇳🇱Netherlands seanB Netherlands

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024