diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-09-04 02:20:48 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-09-04 02:20:48 +0200 |
| commit | 7a4b905ddb64bdc92b7f9acf2ccde9bd84d7a6f3 (patch) | |
| tree | cc9c7025c2b2d7fc31571b3589ecabcb6f63d8c2 /packages/meshbay-node/src/meshbay_node/keystore.py | |
| parent | 5022f2be149e40ac5bdd5fc362e926f3edcf44f0 (diff) | |
| download | meshbay-7a4b905ddb64bdc92b7f9acf2ccde9bd84d7a6f3.tar.gz | |
fix(node): pin utf-8 (and LF) on every text file the node reads or writes
node.toml, the keystore envelope, the unlock key, the loopback UI token,
pairing/invite code files and the denylist were all read and written with
the platform default encoding and newline translation. On Windows that is
cp1252 + CRLF: a node.toml or keystore holding any non-ASCII byte failed to
load, and ops.py's line-based node.toml editor round-tripped CRLF in and
LF out.
Every read is now `encoding="utf-8"`; every write is `encoding="utf-8",
newline="\n"` so the files stay LF whatever the OS. No-op where the locale
was already UTF-8.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/keystore.py')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/keystore.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/keystore.py b/packages/meshbay-node/src/meshbay_node/keystore.py index dff443d..00e504e 100644 --- a/packages/meshbay-node/src/meshbay_node/keystore.py +++ b/packages/meshbay-node/src/meshbay_node/keystore.py @@ -105,7 +105,7 @@ def _resolve_password(unlock_file: Path | None = None) -> str: mode, key_file, ) log.debug("Keystore password from %s", key_file) - return key_file.read_text().strip() + return key_file.read_text(encoding="utf-8").strip() # 3. Interactive prompt return getpass.getpass("MeshBay node keystore password: ") @@ -173,7 +173,7 @@ def load_keystore( raise FileNotFoundError(f"Keystore not found: {path} — run: meshbay-node init") pwd = password or _resolve_password(unlock_file) - envelope = json.loads(path.read_text()) + envelope = json.loads(path.read_text(encoding="utf-8")) if envelope.get("version") != KEYSTORE_VERSION: raise ValueError(f"Unsupported keystore version: {envelope.get('version')}") @@ -236,7 +236,7 @@ def _write_keystore(path: Path, keys: NodeKeys, password: str) -> None: "tag_b64": base64.b64encode(tag).decode(), "ciphertext_b64": base64.b64encode(ct).decode(), } - path.write_text(json.dumps(envelope, indent=2)) + path.write_text(json.dumps(envelope, indent=2), encoding="utf-8", newline="\n") chmod_private(path) |