Skip to content

Buffer overruns and encodings - #19471

Merged
niik merged 4 commits into
developmentfrom
use-the-encoding-luke
Nov 7, 2024
Merged

niik merged 4 commits into
developmentfrom
use-the-encoding-luke

Conversation

@niik

@niik niik commented Oct 30, 2024

Copy link
Copy Markdown
Member

Description

Builds on top of #19470

This fixes a bug where if a user attempts to view the diff for a file which is greater than 256kb (note that the diff may be smaller) we will fail to perform any syntax highlighting of said file.

This is because the maxBuffer argument to execFile will throw an error if the stdout (or stderr) output exceeds the limit but that error will include the partial output collected up until the limit.

A good way to test this is to make a change in our changelog.json (which is ~300k) and observe that the diff is not highlighted and that there's an error message in the console. This was accidentally introduced in 840bbf5 which made getPartialBlobContentsCatchPathNotInRef use git (i.e. execFile) rather than spawnAndComplete which handled buffer overruns.

The whole reason for having this limit in the first place is so that we don't spend unbound time in CodeMirror's language parser trying to highlight enormous files. So a change made to a file after the first 256kb will not be highlighted and that's expected behavior.

Screenshots

Release notes

Notes:

@niik
niik marked this pull request as ready for review October 30, 2024 11:14
Base automatically changed from remove-spawnandcomplete to expose-encoding-overloads November 5, 2024 10:05
Base automatically changed from expose-encoding-overloads to development November 5, 2024 12:46

@sergiou87 sergiou87 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! 👏

@niik
niik merged commit e61330e into development Nov 7, 2024
@niik
niik deleted the use-the-encoding-luke branch November 7, 2024 12:30
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.

2 participants