Skip to content

Handle empty path expansion#236

Open
QuantumEntangledAndy wants to merge 1 commit into
borisbabic:masterfrom
QuantumEntangledAndy:fix/empty_expandpath
Open

Handle empty path expansion#236
QuantumEntangledAndy wants to merge 1 commit into
borisbabic:masterfrom
QuantumEntangledAndy:fix/empty_expandpath

Conversation

@QuantumEntangledAndy

Copy link
Copy Markdown

I was getting an issue on Linux specifically

  File "site-packages/browser_cookie3/__init__.py", line 144, in _expand_paths_impl
    for path in paths:
                ^^^^^
  File "<frozen posixpath>", line 232, in expanduser

Investigation showed that

self.v11_empty_key = PBKDF2(
b'', self.salt, self.length, iterations)
cookie_file = self.cookie_file or _expand_paths(
linux_cookies, 'linux')

has an empty path for linux_cookies for browsers such as Arc which is I believe correct since there is no linux path for this browser

The issue is that the current implementation tries all browsers and for any browser where the linuxpath is not set it would error for linux.

To fix this I altered _expand_path_impl to handle empty (i.e. None) as an empty list instead

def _expand_paths_impl(paths: list, os_name: str):
"""Expands user paths on Linux, OSX, and windows"""
os_name = os_name.lower()

def _expand_paths_impl(paths: list | None, os_name: str):
    """Expands user paths on Linux, OSX, and windows"""
    if paths is None:
         paths = []
    os_name = os_name.lower()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant