Some escaped CSS class names do not work

Created on 12 October 2023, 9 months ago

Problem/Motivation

Escaping symbols in CSS class names works with a leading backslash and a hex number (followed by a space if the symbol escaped to a hex number is followed 0-9A-F). This module's middleware mis-interpreted those escaped CSS class names as regex placeholders in some cases.

Steps to reproduce

Create a class name with a colon in it, e.g. a TailwindCSS class name with an arbitrary value:

<div class="[transform:rotate(-90deg)_translate(50px,0px)]">test</div>

Tailwind's output escapes the class name to

.\[transform\:rotate\(-90deg\)_translate\(50px\2c 0px\)\] {
  transform: rotate(-90deg) translate(50px,0px);
}

The \2 part of the encoded colon \2c was interpreted as regex placeholder and removed.

Proposed resolution

Use str_ireplace instead of preg_replace to inject the compiled CSS at the end of the HTML </head>

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡¦πŸ‡ΉAustria hudri Austria

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

Comments & Activities

Production build 0.69.0 2024