Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with inline <style> CSS optimization when CSS contains < character #605

Open
SumiHeart opened this issue Dec 17, 2023 · 2 comments
Open

Comments

@SumiHeart
Copy link

I've encountered an issue with the inline CSS optimization feature of the LiteSpeed Cache plugin. It appears that the plugin's CSS optimization process is not handling inline <style> tags correctly when the CSS contains the < character, such as in CSS @property syntax.

Issue Description:
The inline CSS within <style> tags that include CSS properties with syntax like @property --image-title-bg{syntax:'<color>'; ...} or list-style-image: url('data:image/svg+xml;utf8,<svg xmlns... are not being optimized to all css in <style>. It seems that the < character is causing the regex pattern used for matching and optimizing inline CSS to terminate prematurely.

Actual Behavior:
The inline CSS is not optimized, and the CSS content after the < character seems to be ignored by the optimization process.

I tried to change the matching code to the following code, and it can be matched for the time being. I hope you can help me update to solve the problem.

preg_match_all('#<link ([^>]+)/?>|<style([^>]*)>((?:(?!</style>).)*)</style>#isU', $content, $matches, PREG_SET_ORDER);

I hope this information is helpful for diagnosing and resolving the issue. Please let me know if you need any further details or if I can assist in any way.

Thank you.

@timotei-litespeed
Copy link
Contributor

Hello
Thank you for your report. We will look into it and come back with an answer

@Tymotey
Copy link
Contributor

Tymotey commented Jul 29, 2024

@SumiHeart I have push you can test: timotei-litespeed@c2ebbee
by using Beta Test from Toolbox: https://docs.litespeedtech.com/lscache/lscwp/toolbox/#beta-test-tab

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants