From 589b8c9a75fb1cc1add94d336f4a6c85b10e82b9 Mon Sep 17 00:00:00 2001 From: Wentao Wu Date: Mon, 16 Dec 2024 06:40:03 +0000 Subject: [PATCH] chore(cloud): keep up the first 5 characters for cloud redact --- midealocal/cloud.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/midealocal/cloud.py b/midealocal/cloud.py index bb1626fa..9039c803 100644 --- a/midealocal/cloud.py +++ b/midealocal/cloud.py @@ -112,7 +112,7 @@ def get_preset_account_cloud() -> dict[str, str]: } -block = "\u2588" +block = "*" def _redact_data(data: str) -> str: @@ -132,8 +132,10 @@ def _redact_data(data: str) -> str: if len(item) == 0: break m = len(item) - elm = r"\b" + item + r"\b" - data = re.sub(elm, block * m, data) + visible = item[:5] # Keep up to the first 5 characters + redacted = visible + block * (m - len(visible)) # Use block for masking + elm = re.escape(item) # Escape regex metacharacters + data = re.sub(elm, redacted, data) return data