Skip to content

Commit 3df9836

Browse files
committed
Fix regex for Linux FTP not recognizing sticky/SUID/SGID permissions
1 parent 4efe083 commit 3df9836

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

fs/_ftp_parse.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
RE_LINUX = re.compile(
2020
r"""
2121
^
22-
([ldrwx-]{10})
22+
([-dlpscbD])
23+
([r-][w-][xsS-][r-][w-][xsS-][r-][w-][xtT-][\.\+]?)
2324
\s+?
2425
(\d+)
2526
\s+?
@@ -110,14 +111,14 @@ def _decode_linux_time(mtime):
110111

111112

112113
def decode_linux(line, match):
113-
perms, links, uid, gid, size, mtime, name = match.groups()
114-
is_link = perms.startswith("l")
115-
is_dir = perms.startswith("d") or is_link
114+
ty, perms, links, uid, gid, size, mtime, name = match.groups()
115+
is_link = ty == "l"
116+
is_dir = ty == "d" or is_link
116117
if is_link:
117118
name, _, _link_name = name.partition("->")
118119
name = name.strip()
119120
_link_name = _link_name.strip()
120-
permissions = Permissions.parse(perms[1:])
121+
permissions = Permissions.parse(perms)
121122

122123
mtime_epoch = _decode_linux_time(mtime)
123124

0 commit comments

Comments
 (0)