pw-dump output pipewire.sec.label is not always utf-8
i wanted to parse the output of pw-dump
, but it seems the output is not valid utf-8:
pw-dump -N | isutf8 -v
(standard input): line 578, char 33, byte 17439: Expecting bytes in the following ranges: 00..7F C2..F4.
65 6C 22 3A 20 22 D0 A1 BB EA FD 7F 22 2C 0A | el": "......",.
^^ | ^
and here some python test:
import subprocess
import json
#text = subprocess.run(["pw-dump", "-N"], capture_output=True, text=True).stdout
# above fails cause pw-dump output not valid utf-8?
text = subprocess.run(["pw-dump", "-N"], capture_output=True).stdout
data = json.loads(text)
print(data)
that errors out at the same point in input data:
python3 test.py
Traceback (most recent call last):
File "test.py", line 7, in <module>
data = json.loads(text)
File "/usr/lib/python3.9/json/__init__.py", line 341, in loads
s = s.decode(detect_encoding(s), 'surrogatepass')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xbb in position 17439: invalid start byte
if i pipe the output of pw-dump -N
to a file, and look at it in my editor, some (all?) pipewire.sec.label
entries look odd:
"pipewire.sec.label": "���",
"pipewire.sec.label": "\u0003"�:�!V,
"pipewire.sec.label": 0,
"pipewire.sec.label": "\b",
"pipewire.sec.label": "���",
fwiw, all above have these kind of parents:
"id": <DIFFERENT>,
"type": "PipeWire:Interface:Client",
"version": 3,
"permissions": [ "r", "w", "x", "m" ],
"info": {
"change-mask": [ "props" ],
"props": {
"pipewire.protocol": "protocol-native",
"pipewire.sec.pid": <DIFFERENT>,
"pipewire.sec.uid": 1000,
"pipewire.sec.gid": 1000,
i searched a little in source and think it could have something to do with PW_KEY_SEC_LABEL
and src/modules/module-protocol-native.c
but i don't actually know what i'm reading.
i'm on archlinux with pipewire 0.3.24, and wonder if it's just my system...