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

Stitches example: Greedy regexp pattern potentially breaks markup #341

Closed
nimajneb opened this issue Sep 15, 2023 · 1 comment
Closed

Stitches example: Greedy regexp pattern potentially breaks markup #341

nimajneb opened this issue Sep 15, 2023 · 1 comment

Comments

@nimajneb
Copy link
Contributor

Hi!

The stitches example uses a Regexp pattern to replace the style tag in SSR with the actual server side rendered styles.

However, the pattern used to do this is too greedy. I just had an example in which I have multiple additional style tags also in the the whole document body, which got all replaced until the last closing style tag.

By replacing .* with .*? I believe this issue should be fixed.

Additionally, also matching newlines by using the /s flag might avoid another issue in case the SSR stylesheet contains newlines, though I am unsure how much of an edge case this is.

@nimajneb
Copy link
Contributor Author

I just quickly created a PR in case you want to address the issue directly. Cheers!

@nimajneb nimajneb changed the title Stitches example: Markup potentially broken Stitches example: Greedy regexp pattern potentially breaks markup Sep 15, 2023
@machour machour closed this as completed May 20, 2024
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

2 participants