Skip to content

Fix Logger.Utils.truncate_n UTF-8 range for two-byte code points#15221

Merged
josevalim merged 1 commit intoelixir-lang:mainfrom
cuiweixie:fix/logger-truncate-n-utf8-boundary
Mar 27, 2026
Merged

Fix Logger.Utils.truncate_n UTF-8 range for two-byte code points#15221
josevalim merged 1 commit intoelixir-lang:mainfrom
cuiweixie:fix/logger-truncate-n-utf8-boundary

Conversation

@cuiweixie
Copy link
Copy Markdown
Contributor

@cuiweixie cuiweixie commented Mar 27, 2026

Summary

  • Adjust the two-byte UTF-8 code point guard from 127..0x07FF to 128..0x07FF. Two-byte UTF-8 sequences start at U+0080 (128); U+007F (127) is still a single byte. The old range overlapped the 0..127 clause and could misclassify U+007F if clause order ever changed.
  • Add regression tests in Logger.UtilsTest for U+007F/U+0080 byte boundaries.

@josevalim
Copy link
Copy Markdown
Member

@cuiweixie is the test failing before you change? The change is technically correct but this range overlaps with the previous clause, so the previous clause will always match and the test would always pass before too. If that's the case, you can only do the code change. No need for a new test. Thanks!

Two-byte UTF-8 sequences start at U+0080 (128), not U+007F (127). The
previous guard `127..0x07FF` overlapped the single-byte clause and could
misclassify U+007F if clause order changed.

Add regression tests for U+007F/U+0080 byte boundaries.
@cuiweixie cuiweixie force-pushed the fix/logger-truncate-n-utf8-boundary branch from ec36035 to bace473 Compare March 27, 2026 09:11
@cuiweixie
Copy link
Copy Markdown
Contributor Author

@cuiweixie is the test failing before you change? The change is technically correct but this range overlaps with the previous clause, so the previous clause will always match and the test would always pass before too. If that's the case, you can only do the code change. No need for a new test. Thanks!

got it. only do code change without adding unittest.

@josevalim josevalim merged commit f16d2a3 into elixir-lang:main Mar 27, 2026
15 checks passed
@josevalim
Copy link
Copy Markdown
Member

💚 💙 💜 💛 ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants