Skip to content

fix: preserve a leading BOM when set_key and unset_key rewrite a file - #755

Open
MohammedAlkindi wants to merge 4 commits into
theskumar:mainfrom
MohammedAlkindi:fix/preserve-bom-on-rewrite
Open

MohammedAlkindi wants to merge 4 commits into
theskumar:mainfrom
MohammedAlkindi:fix/preserve-bom-on-rewrite

Conversation

@MohammedAlkindi

Copy link
Copy Markdown
Contributor

Reopens #687, which closed when I deleted my fork by mistake. The commits are unchanged.

set_key and unset_key dropped a leading UTF-8 BOM. #640 stripped it for parsing, but the bindings never received it, so the rewrite lost it. rewrite() now keeps the BOM, and only files that already had one change. The new tests fail on main and pass here, and the full suite passes.

The parser strips a leading UTF-8 BOM so the first variable is read
correctly, but the stripped BOM never reaches the bindings that set_key
and unset_key write back out. Rewriting a file that had one therefore
dropped it silently, changing a part of the file the caller did not ask
to touch.

Carry it across in rewrite(), which both writers share.

This branch has not been deployed

No deployments
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