Skip to content

Accept a UTF-8 BOM on standard input - #277

Merged
stefankoegl merged 1 commit into
stefankoegl:masterfrom
boogu2005:fix/utf8-bom-standard-input
Nov 25, 2026
Merged

stefankoegl merged 1 commit into
stefankoegl:masterfrom
boogu2005:fix/utf8-bom-standard-input

Conversation

@boogu2005

Copy link
Copy Markdown
Contributor

Both command-line tools accept UTF-8 files with a byte-order mark when opened by filename, but reject the same input when it is piped through stdin. This also affects patches piped to jsonpatch without a PATCH argument.

Strip one leading byte-order mark in the shared CLI loader before parsing, so named files and stdin use the same handling.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

There are no active review issues for the change unifying UTF-8 BOM handling for files and standard input.

No open issues 🎉

What changed in this PR

Makes UTF-8 byte-order mark handling consistent for named files and standard input in both command-line tools.

Changes:

  • Strip one leading BOM in the shared JSON loader rather than during file decoding.
  • Add stdin regression tests for both jsondiff inputs and jsonpatch document and patch inputs, including an omitted PATCH argument.
File Description
tests.py Adds coverage for BOM-prefixed documents and patches supplied through stdin.
jsonpatch_cli.py Uses UTF-8 file decoding and centralizes leading BOM removal in _load.

Review effort: Balanced

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 100.0%. remained the same — boogu2005:fix/utf8-bom-standard-input into stefankoegl:master

@stefankoegl
stefankoegl merged commit d6289cb into stefankoegl:master Nov 25, 2026
22 checks passed
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.

4 participants