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

Fix maskInlineIgnore to handle non-ascii input #279

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

Conversation

kian99
Copy link

@kian99 kian99 commented May 7, 2024

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features) see docs/README.md

What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug-fix

What is the current behavior? (You can also link to an open issue here)
#278 - Crash when running against non-ascii input.

What is the new behavior (if this is a feature change)?
No crash on non-ascii input.

Does this PR introduce a breaking change? (What changes might users need to make due to this PR?)
No

Other information:
The maskInlineIgnore would be converted to a slice of runes, but the length of a slice of runes is not equal to the length of a string when non-ascii characters are present. In the rune representation, each index element is a 32-bit code-point while len(string) returns the number of bytes in the string. A good reference is https://go.dev/blog/strings

I've opted to use the already existing ignoreRuleRegex to replace the characters that were previously being replaced with null terminators. I've also added some tests for this.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋 Thanks for submitting your first PR!

Please be sure to read and follow our Code of Conduct and Contributing guide.

⭐️ Is your org or open source project using woke? If so, we'd love for you to be included in the 'Who uses woke' list at https://github.com/get-woke/woke/blob/main/docs/about.md#who-uses-woke.

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.

None yet

1 participant