Skip to content

fix: strip trailing null bytes from pbxproj before parsing#149

Open
yocontra wants to merge 1 commit intoapache:masterfrom
yocontra:fix/strip-null-bytes
Open

fix: strip trailing null bytes from pbxproj before parsing#149
yocontra wants to merge 1 commit intoapache:masterfrom
yocontra:fix/strip-null-bytes

Conversation

@yocontra
Copy link

Summary

Some runtimes (notably Bun) and filesystems (APFS) can produce files with trailing null byte padding after fs.writeFileSync. When the xcode library reads a .pbxproj file that has been written this way, the PEG parser fails with:

SyntaxError: Expected end of input but "\0" found.

The actual pbxproj content is valid — only trailing \0 bytes cause the parse failure.

Changes

  • lib/pbxProject.js (parseSync): Strip trailing null bytes before passing to parser
  • lib/parseJob.js (async parse): Same fix for the forked worker path

The fix is a single .replace(/\0+$/, '') on the file contents string, applied after readFileSync and before parser.parse().

Reproduction

  1. Use Bun to run Expo prebuild (bun expo prebuild --platform ios --clean)
  2. A config plugin calls withXcodeProject which triggers parseSync
  3. The generated project.pbxproj has ~16KB of trailing null bytes
  4. Parser throws SyntaxError: Expected end of input but "\0" found

Test plan

  • Existing tests continue to pass (no null bytes = no-op regex replace)
  • Files with trailing null bytes now parse successfully

Some runtimes (notably Bun) and filesystems (APFS) can produce files with
trailing null byte padding. The PEG parser rejects \0 characters, causing
a SyntaxError even though the actual pbxproj content is valid.

Strip trailing null bytes before passing file contents to the parser.
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