FIX: Bug [0001719] FTP shows ".." parent directory entry without access rights

This commit is contained in:
Alexander Koblov 2018-04-07 10:12:45 +00:00
commit 2ae6b95a7d
2 changed files with 34 additions and 15 deletions

View file

@ -3,7 +3,7 @@
-------------------------------------------------------------------------
WFX plugin for working with File Transfer Protocol
Copyright (C) 2009-2017 Alexander Koblov (alexx2000@mail.ru)
Copyright (C) 2009-2018 Alexander Koblov (alexx2000@mail.ru)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
@ -51,6 +51,8 @@ type
TFTPListEx = class(TFTPList)
private
FIndex: Integer;
protected
procedure FillRecord(const Value: TFTPListRec); override;
public
procedure Clear; override;
procedure Assign(Value: TFTPList); override;
@ -192,6 +194,19 @@ begin
inherited Clear;
end;
procedure TFTPListEx.FillRecord(const Value: TFTPListRec);
var
flr: TFTPListRecEx;
begin
inherited FillRecord(Value);
if Value.Directory and (Value.FileName = '..') then
begin
flr := TFTPListRecEx.Create;
flr.Assign(Value);
FList.Add(flr);
end;
end;
procedure TFTPListEx.Assign(Value: TFTPList);
var
flr: TFTPListRecEx;
@ -550,6 +565,9 @@ begin
ConvertFromUtf8:= @UTF8ToKOI8;
end;
FFtpList.Free;
FFtpList:= TFTPListEx.Create;
// Move mostly used UNIX format to first
FFtpList.Masks.Exchange(0, 2);
// Windows CE 5.1 (insert before BullGCOS7)

View file

@ -33,7 +33,7 @@ type
implementation
uses
uOSUtils, DCStrUtils, uFile, WfxPlugin, uWfxModule, uLog, uLng;
DCFileAttributes, DCStrUtils, uFile, WfxPlugin, uWfxModule, uLog, uLng;
function TWfxPluginListOperation.UpdateProgress(SourceName, TargetName: String;
PercentDone: Integer): Integer;
@ -69,28 +69,21 @@ end;
procedure TWfxPluginListOperation.MainExecute;
var
FindData : TWfxFindData;
Handle: THandle;
aFile: TFile;
Handle: THandle;
FindData : TWfxFindData;
HaveUpDir: Boolean = False;
begin
with FWfxPluginFileSource.WFXModule do
begin
try
FFiles.Clear;
if not FileSource.IsPathAtRoot(Path) then
begin
aFile := TWfxPluginFileSource.CreateFile(Path);
aFile.Name := '..';
aFile.Attributes := faFolder;
FFiles.Add(aFile);
end;
Handle := WfxFindFirst(FCurrentPath, FindData);
if Handle <> wfxInvalidHandle then
try
repeat
CheckOperationState;
if (FindData.FileName = '.') or (FindData.FileName = '..') then Continue;
if (FindData.FileName = '.') then Continue;
if (FindData.FileName = '..') then HaveUpDir:= True;
aFile := TWfxPluginFileSource.CreateFile(Path, FindData);
FFiles.Add(aFile);
@ -98,6 +91,14 @@ begin
finally
FsFindClose(Handle);
end;
finally
if not HaveUpDir then
begin
aFile := TWfxPluginFileSource.CreateFile(Path);
aFile.Name := '..';
aFile.Attributes := GENERIC_ATTRIBUTE_FOLDER;
FFiles.Insert(aFile, 0);
end;
end; // with
end;