Conversation
Change buffer encoding from binary to UTF-8 for data accumulation.
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.
Summary
git pushthroughgit-remote-overleafsilently drops files whose contents containnon-ASCII characters, e.g. any UTF-8 LaTeX source with Chinese comments. In a 12-file
test tree the first push reported success, but only 6 files reached the project:
main.tex,ref.bib,build.sh,.gitignoreand two section files never arrived, andthe file deleted in that commit was not deleted either. Content that does get through is
mangled, because the same code path re-encodes it as latin1.
Root cause
parseFastExport()reads the fast-export stream line by line and re-joins the lines of adata <N>section (src/remote-helper.ts:189):data <N>counts UTF-8 bytes, but'binary'(latin1) encodes every character as asingle byte. For a blob containing non-ASCII text the accumulated buffer is systematically
short, so the
>= pendingDataBytescheck fires late: the parser stays in thedatastateand swallows the following
M <mode> :<mark> <path>/blob/marklines as blobcontent. Files whose
Mline is consumed that way are never added tofilesand neveruploaded.
Deficits measured on the test tree (UTF-8 length vs. latin1 length):
.gitignorebuild.shmain.texref.bibgit pull/git fetchare not affected: the import path writesentry.getData()buffers directly to stdout.
Fix
One line, so the byte count matches
data <N>again:Verification
place, and
olcli diffstill reported 6 missing files..git/overleaf/marks,.git/overleaf/state.jsonandrefs/overleaf/mainand pushed again. The debug log (GIT_REMOTE_OVERLEAF_DEBUG=1)shows all 12 files uploaded and the deleted path removed.
local working tree: 12/12 identical, including the files with Chinese text, and no
remote-only files left.
olcli diffreports no differences.Repro
Scope
This fixes text content (valid UTF-8), which is what Overleaf projects contain. Genuinely
binary blobs are still decoded by
readlineas UTF-8, so PNG/PDF payloads remainunsupported on push; fixing that properly means reading
data <N>as raw bytes instead ofgoing through
readline. I left that out to keep this change minimal — happy to follow upif you want it.
There is no automated test here:
parseFastExport()is not exported, and the existingtests cover the client/config/ignore layers. I can add a regression test if you are open
to exporting the function (or extracting the stream parser).