Skip to content

Commit

Permalink
Merge pull request #1272 from MetPX/issue1270
Browse files Browse the repository at this point in the history
Issue1270 - fixing relative symlinks with (inappropriate) ../../ in them...
  • Loading branch information
petersilva authored Oct 25, 2024
2 parents 247faba + 5b7179a commit 7bea2c0
Showing 1 changed file with 1 addition and 10 deletions.
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

0 comments on commit 7bea2c0

Please sign in to comment.