Skip to content

Keep NUL bytes in FilterList.apply_to_* and Repository.raw_message - #1510

Merged
jdavid merged 2 commits into
libgit2:masterfrom
Grinv:filterlist-nul-bytes
Nov 6, 2026
Merged

jdavid merged 2 commits into
libgit2:masterfrom
Grinv:filterlist-nul-bytes

Conversation

@Grinv

@Grinv Grinv commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #1507. FilterList.apply_to_buffer, apply_to_file, apply_to_blob and Repository.raw_message now read buf.size bytes from their git_buf instead of stopping at the first NUL. Repository.message decodes raw_message, so it also keeps text after a NUL.

ffi.pyi gets GitBufC.size and the optional size argument of ffi.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.

Grinv added 2 commits November 6, 2026 07:30
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
Grinv force-pushed the filterlist-nul-bytes branch from 8923cb9 to 095a3cf Compare November 5, 2026 23:30
@jdavid
jdavid merged commit 095a3cf into libgit2:master Nov 6, 2026
18 checks passed
@Grinv
Grinv deleted the filterlist-nul-bytes branch November 6, 2026 10:13
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.

FilterList.apply_to_* truncate output at the first NUL byte

2 participants