String containing NUL is written but can't be read back
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- swift
- Domain
- build-system
Research direction
Start at jsonRepresentation() and the JSONSerialization reader configured with .json5Allowed; reproduce the NUL round trip from the example on the referenced main revision. Resolve whether NUL is invalid or the reader should accept the writer's escaped form, then add coverage for the chosen behavior and verify other string fields.
Written by the indexing model from the issue text.
Description
A string with a NUL in it gets written, but the library can't read the file back:
var project = try XCSchema.Project(jsonRepresentation: Data(#"{"default-configuration":"Debug","localizations":{"development":"en"},"files":[]}"#.utf8))
project.buildSettings["FOO"] = .string("a\u{0}b")
let data = try project.jsonRepresentation() // succeeds
_ = try XCSchema.Project(jsonRepresentation: data) // throws "The data couldn't be read because it isn't in the correct format."
The writer escapes the NUL as a JSON unicode escape. The reader uses JSONSerialization with .json5Allowed, and Foundation's JSON5 scanner rejects escaped nulls ("Unsupported escaped null"), though plain JSON mode accepts them. Any string field hits this.
If NUL isn't meant to be allowed, jsonRepresentation() should throw instead of writing the file.
main @ c132630, macOS 26, Swift 6.3.3
- Dominant language
- Swift
- Stars
- 384
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apple/xcode-project-format
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
bug
Difficulty 3/5 1-2 days Newbie friendliness 72/100
All issues in apple/xcode-project-format
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
type: docs
Difficulty 1/5 Under an hour Newbie friendliness 95/100
googleapis/google-cloud-swift#971 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bitcoindevkit/bdk-ffi#1125 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
mozilla-mobile/firefox-ios#35743 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
manaflow-ai/cmux#13417 ·