Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue1270 - fixing relative symlinks with (inappropriate) ../../ in them... #1272

Merged
merged 3 commits into from
Oct 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 1 addition & 10 deletions sarracenia/flow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,12 +890,9 @@ def updateFieldsAccepted(self, msg, urlstr, pattern, maskDir,
if f in msg['fileOp']:
fopv = msg['fileOp'][f].split('/')
# an absolute path file posted is relative to '/' (in relPath) but the values in
# the link and rename fields may be absolute, requiring and adjustmeent when stripping
# the link and rename fields may be absolute, requiring and adjustment when stripping
if fopv[0] == '':
strip += 1
elif len(fopv) == 1:
toclimb=len(token)-1
msg['fileOp'][f] = '../'*(toclimb) + fopv[0]
if len(fopv) > strip:
rest=fopv[strip:]
toclimb=len(token)-rest.count('..')-1
Expand Down Expand Up @@ -947,9 +944,6 @@ def updateFieldsAccepted(self, msg, urlstr, pattern, maskDir,
if (f in msg['fileOp']) :
if msg['fileOp'][f].startswith(self.o.baseDir):
msg['fileOp'][f] = msg['fileOp'][f].replace(self.o.baseDir, d, 1)
elif os.sep not in msg['fileOp'][f]:
toclimb=len(token)-1
msg['fileOp'][f] = '../'*(toclimb) + msg['fileOp'][f]

elif 'fileOp' in msg and new_dir:
u = sarracenia.baseUrlParse(msg['baseUrl'])
Expand All @@ -958,9 +952,6 @@ def updateFieldsAccepted(self, msg, urlstr, pattern, maskDir,
if (len(u.path) > 1):
if msg['fileOp'][f].startswith(u.path):
msg['fileOp'][f] = msg['fileOp'][f].replace(u.path, new_dir, 1)
elif '/' not in msg['fileOp'][f]:
toclimb=len(token)-1
msg['fileOp'][f] = '../'*(toclimb) + msg['fileOp'][f]

if self.o.mirror and len(token) > 1:
new_dir = new_dir + '/' + '/'.join(token[:-1])
Expand Down
Loading