Repository navigation
Conversation
A file starting with a UTF-16 LE or BE byte order mark was read as UTF-8 after the mark was dropped, so its names and values held NUL bytes. It is now decoded as UTF-16 before parsing (#66).
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the pull request
Windows tools such as Notepad save "Unicode" files as UTF-16 with a byte order mark.
skipBOMdropped the mark but parsed the remaining bytes as UTF-8, so every name and value held NUL bytes.f.Section("author")ontestdata/UTF-16-LE-BOM.inifound nothing. The existing UTF-16 tests only checked thatLoaddidn't fail, and the BE one was empty.parsenow decodes input that starts withFF FEorFE FFas UTF-16 LE or BE before lexing, usingunicode/utf16, so no dependency is added. Neither prefix is valid UTF-8, so UTF-8 input can't be affected. Surrogate pairs decode, and a trailing odd byte becomes U+FFFD.Writestill writes UTF-8, and the migration guide says so. UTF-16 without a byte order mark isn't detected.Link to the issue: closes #66
Checklist
AI usage
Written by Amp (an AI coding agent) at the maintainer's request. Validation:
go test ./...,go vet, and 40 s ofFuzzWriteRoundTrip. The LE, BE and non-ASCII tests (CJK names, an emoji surrogate pair, CRLF line ends, an odd trailing byte) all fail onmain.