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

Add support in regular expressions for UTF-8 whitespace detection #1787

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zachmccormick
Copy link

@zachmccormick zachmccormick commented Feb 15, 2024

We ran across a nasty bug at Braze where a customer was supplying the UTF-8 non-breaking space character in a Liquid template they were providing to us, and it took a very long time to debug why it was not parsing correctly. It turns out that the user-supplied Liquid string had some UTF-8 non-breaking spaces in it, which the current regular expressions do not count as whitespace (\s only includes ASCII whitespace, while [[:space:]] includes ASCII and UTF-8 whitespace characters).

I replaced \s everywhere, but I added a single test case that red-greens against the existing code. Getting full coverage of every possibility seemed excessive, although I'm open to implementing more thorough tests if it's needed before merging.

Co-authored-by: Chris Watkins [email protected]

@zachmccormick
Copy link
Author

I have signed the CLA!

@zachmccormick
Copy link
Author

zachmccormick commented Feb 15, 2024

It may also be smart to replace \w with [[:word:]] to work properly with non-ASCII word characters as well, however I would imagine those are easier to spot visually and probably don't get accidentally used.

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

Successfully merging this pull request may close these issues.

1 participant