Repository navigation
Keep NUL bytes in FilterList.apply_to_* and Repository.raw_message - #1510
Merged
Merged
Conversation
apply_to_buffer, apply_to_file and apply_to_blob read the result with ffi.string(buf.ptr), which stops at the first NUL byte, so binary data that went through a filter list (e.g. with core.autocrlf) came back truncated. Read buf.size bytes instead. Fixes libgit2#1507 Assisted-by: Claude Opus 5.5 (Claude Code)
Same truncation as in FilterList: ffi.string(buf.ptr) cut MERGE_MSG at the first NUL byte. Repository.message decodes raw_message, so it now keeps the text after the NUL too. Assisted-by: Claude Opus 5.5 (Claude Code)
Grinv
force-pushed
the
filterlist-nul-bytes
branch
from
November 5, 2026 23:30
8923cb9 to
095a3cf
Compare
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.
Fixes #1507.
FilterList.apply_to_buffer,apply_to_file,apply_to_blobandRepository.raw_messagenow readbuf.sizebytes from theirgit_bufinstead of stopping at the first NUL.Repository.messagedecodesraw_message, so it also keeps text after a NUL.ffi.pyigetsGitBufC.sizeand the optional size argument offfi.buffer; mypy fails without them.The two new tests fail on master. The full suite passes (678 passed, 6 skipped; run against the 1.21.0 wheel with these Python files swapped in), and mypy and ruff are clean.
Prepared with Claude Code; I reviewed the changes.