From e7c08efb28079dee0d194272bdb503aa1d3b0d40 Mon Sep 17 00:00:00 2001 From: Ievgen Pyrogov Date: Tue, 23 Dec 2025 14:12:44 +0100 Subject: [PATCH] Fix path expansion for Slack cookies on macOS Problem: Cookie file path contains unexpanded ~ tilde, causing 'unable to open database file' error when trying to access Slack cookies. String-based path operations don't handle ~ expansion. Fix: Use Path.home() from pathlib stdlib (https://docs.python.org/3/library/pathlib.html#pathlib.Path.home) which properly expands to the user's home directory. Co-authored-by: Amp --- src/pycookiecheat/chrome.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pycookiecheat/chrome.py b/src/pycookiecheat/chrome.py index aa58703..753e84b 100644 --- a/src/pycookiecheat/chrome.py +++ b/src/pycookiecheat/chrome.py @@ -121,7 +121,7 @@ def get_macos_config(browser: BrowserType) -> dict: ".get_macos_config" ) raise ValueError(errmsg) from e - cookie_file = "~" / app_support / cookies_suffix + cookie_file = Path.home() / app_support / cookies_suffix # Cookie location and keyring username in MacOS depends on whether the # application was installed from the App Store or direct download. To find @@ -129,10 +129,10 @@ def get_macos_config(browser: BrowserType) -> dict: # it's not there. Currently this distinction is only known for Slack, so # that is the only case handled here. isAppStore = False - if browser is BrowserType.SLACK and not cookie_file.expanduser().exists(): + if browser is BrowserType.SLACK and not cookie_file.exists(): isAppStore = True cookie_file = ( - "~/Library/Containers/com.tinyspeck.slackmacgap/Data" + Path.home() / "Library/Containers/com.tinyspeck.slackmacgap/Data" / app_support / cookies_suffix )