two similar bugs have been reprted by
FRENCH CANCAN and
TSGUsing the macro 'ADD TO FOLDER' is broken in section [special:import]
corrected file hfs.exe
HEREto correct this bug, it is necessary to correct main.pas as
function Tmainfrm.findFilebyURL(url:string; root:Tfile=NIL):Tfile;
......
if root.isTemp() then
begin
workTheRestByReal(url, root);
exit;
end;
cur:=root.node; // this line can create an exeption error withcur=NIL and n:=cur.getFirstChild();
if cur=NIL then exit; //bug corrected by mars preserve us from an exception error
while url > '' do
begin
s:=chop('/', url);
......
the second is an update inside the procedure addfolder()
procedure addFolder();
.......
begin
result:='';
if not stringExists(p, ['real','virtual']) then exit;
parent:=NIL;
if assigned(md.folder) then
parent:=md.folder.node;
s:=par(1);
if (s='') or ansiStartsStr('overwrite=',lowercase(s)) then exit; //add by mars bug detected when macro used with bad syntax
if p = 'virtual' then
begin
if not validVFSpath(s) then exit;
f:=Tfile.createVirtualFolder(s);
end
else
begin
if not isAbsolutePath(s) and assigned(md.folder) then
begin
s:=md.folder.resource+'\'+xtpl(s,['/','\','\\','\']); //add by mars
if ansicontainsStr(s,'\..') or ansicontainsStr(s,'..\') then exit; //mod by mars
s:=expandFileName(s); //mod by mars
if not directoryExists(s) then exit;
end;
f:=Tfile.create(s);
s:=par(2);
if validVFSpath(s) and not ansiStartsStr('overwrite=',lowercase(s)) then //mod by mars
f.name:=s;
end;
old:=mainfrm.findFilebyURL(f.name, md.folder); //was create an error exception
if assigned(old) then
if not parexist(['overwrite']) or isTrue(par('overwrite')) then
try old.node.delete() except end // delete existing one
else
begin
f.free;
spaceIf(FALSE);
exit;
end;
if mainfrm.addFile(f, parent, TRUE) = NIL then
f.free
else
spaceIf(TRUE)
end; // addFolder
usage:
{.add to folder|real|absolute-path|vfs-name.} vfs-name created only if the path is valid on hard drive
{.add to folder|real|absolute-path|VFS-name|overwrite=true.} if one vfs-name exist in the vfs then he is deleted and the new created exept if overwrite=0
other possibilities
[special:import] //french cancan
{.add folder|real|..} when new name is ommited , this add the folder name where is stored the new tpl file
{.add folder|real|.} is not a valid macro
{.add folder|real|.||overwrite=0.} same as above but by preserve the existing folder.
by security , if an absolute path contain \.. ,then the macro is aborted: {.add folder|real|..|.} is not a valid macro
if in this case the name is not specified, and when 'overwrite=...' is detected as par(2), then the name is empty.
{.add folder|real|.|overwrite=true.} is a valid macro with no name
[special:import] //tsg
{.add folder|real|template.}
{.set item|/template|hide=1.}
{.set item|/template|no log=1.}
{.add file|filelist.tpl.}
{.set item|/filelist.tpl|hide=1.}
{.set item|/filelist.tpl|no log=1.}
does work with the update.