mirror of
https://github.com/certbot/certbot.git
synced 2026-06-05 06:42:10 -04:00
Raise error with long paths on Windows
This commit is contained in:
parent
5eec69236d
commit
5ce5ca9caa
1 changed files with 10 additions and 4 deletions
|
|
@ -393,17 +393,23 @@ def readlink(link_path):
|
|||
:param str link_path: The symlink path to resolve
|
||||
:return: The path the symlink points to
|
||||
:returns: str
|
||||
:raise: ValueError if a long path (260> characters) is encountered on Windows
|
||||
"""
|
||||
path = os.readlink(link_path)
|
||||
|
||||
if POSIX_MODE or not path.startswith('\\\\?\\'):
|
||||
return path
|
||||
|
||||
# At that point, we are on Windows and the path returned uses the long form (Python 3.8+).
|
||||
|
||||
# Max length of a normal path is 260 characters on Windows, including the non printable
|
||||
# termination character "<NUL>". The termination character is not included in Python
|
||||
# strings, giving a max length of 259 characters, + 4 characters for the extended form
|
||||
# prefix, to an effective max length of the studied path of 263 characters.
|
||||
if not POSIX_MODE and path.startswith('\\\\?\\') and len(path) < 264:
|
||||
path = path[4:]
|
||||
# prefix, to an effective max length 263 characters on a string representing a normal path.
|
||||
if len(path) < 264:
|
||||
return path[4:]
|
||||
|
||||
return path
|
||||
raise ValueError("Long paths are not supported by Certbot on Windows.")
|
||||
|
||||
|
||||
# On Windows is_executable run from an unprivileged shell may claim that a path is
|
||||
|
|
|
|||
Loading…
Reference in a new issue