-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: strip BOM character from templates #13548
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
Conversation
🦋 Changeset detectedLatest commit: bb698f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@@ -0,0 +1 @@ | |||
<div></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BOM characters can only appear at the very beginning of a file. I don't think we need the logic as presented here, we should just look at the very first charcode and remove it if it's a BOM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but I couldn't get a test case that emulated it. :/ Feel free to try if you have an approach that can work.
Also FWIW BOM characters can appear in other places too – we strip them out of the contentEditable with Lexical as they play havoc with text selection.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But isn't it a bug if someone has a BOM character not at the start? Not sure we should handle that / slow down our parser for finding these things. Also, AFAIK a BOM character can also be the start of a valid character sequence that means something completely different.
I think it's ok to not have a test for this, as long as there's a small comment explaining what the code does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the PR to strip BOM once at the start, added a test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Fixes #13519.