Configuration
mas ▁▁▁▁ 7.0.0
slice ▁▁ arm64
slices ▁ arm64
dist ▁▁▁ homebrew/core/mas
origin ▁ https://github.com/mas-cli/mas.git
rev ▁▁▁▁ 7c70ffdfd9f71a654300a78b3b627782e6abe1b4
swift ▁▁ 6.3 (swiftlang-6.3.0.123.5 clang-2100.0.123.102)
driver ▁ 1.148.6
store ▁▁ FR
region ▁ FR
macos ▁▁ 26.4.1 (25E253)
mac ▁▁▁▁ unknown
cpu ▁▁▁▁ Apple M1 Pro
arch ▁▁▁ arm64
Bug description
Every --json-emitting subcommand (search, and by extension list, outdated, lookup/info) can produce JSON in which a string field contains raw, unescaped characters like a literal \n inside description or releaseNotes.
The practical impact is that the output is not safely streamable as newline-delimited JSON (one record per line).
I discovered this while updating my Meta Package Manager project to rely on --json to parse machine readable output: kdeldycke/meta-package-manager@2e12d79
Loosely related to #626 as the latter mentions properly escaping invalid data.
Steps to reproduce
You can reproduce the parse failure with the most natural stream consumer with this one liner:
$ mas search excel --json | python3 -c 'import sys,json; [json.loads(l) for l in sys.stdin if l.strip()]'
...
Traceback (most recent call last):
File "<string>", line 1, in <module>
import sys,json; [json.loads(l) for l in sys.stdin if l.strip()]
~~~~~~~~~~^^^
File "/Users/kde/Library/Application Support/uv/python/cpython-3.14.0+freethreaded-macos-aarch64-none/lib/python3.14t/json/__init__.py", line 346, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/Users/kde/Library/Application Support/uv/python/cpython-3.14.0+freethreaded-macos-aarch64-none/lib/python3.14t/json/decoder.py", line 345, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/kde/Library/Application Support/uv/python/cpython-3.14.0+freethreaded-macos-aarch64-none/lib/python3.14t/json/decoder.py", line 361, in raw_decode
obj, end = self.scan_once(s, idx)
~~~~~~~~~~~~~~^^^^^^^^
json.decoder.JSONDecodeError: Invalid control character at: line 1 column 2516 (char 2515)
Configuration
Bug description
Every
--json-emitting subcommand (search, and by extensionlist,outdated,lookup/info) can produce JSON in which a string field contains raw, unescaped characters like a literal\ninsidedescriptionorreleaseNotes.The practical impact is that the output is not safely streamable as newline-delimited JSON (one record per line).
I discovered this while updating my Meta Package Manager project to rely on
--jsonto parse machine readable output: kdeldycke/meta-package-manager@2e12d79Loosely related to #626 as the latter mentions properly escaping invalid data.
Steps to reproduce
You can reproduce the parse failure with the most natural stream consumer with this one liner: