FIX: Wfx-plugins - don't allow forbidden symbols in the plugin name (issue #1655)

This commit is contained in:
Alexander Koblov 2024-05-20 21:45:50 +03:00
commit 6f9218adcb
3 changed files with 21 additions and 4 deletions

View file

@ -114,6 +114,8 @@ type
function WfxFileTimeToDateTime(FileTime : TWfxFileTime) : TDateTime; inline;
function DateTimeToWfxFileTime(DateTime : TDateTime) : TWfxFileTime; inline;
function RepairPluginName(const AName: String): String;
implementation
uses
@ -161,6 +163,21 @@ begin
end;
end;
function RepairPluginName(const AName: String): String;
var
Index: Integer;
DenySym: set of AnsiChar = ['\', '/', ':'];
begin
Result:= AName;
for Index:= 1 to Length(Result) do
begin
if Result[Index] in DenySym then
begin
Result[Index]:= '_';
end;
end;
end;
{ TWfxTreeBuilder }
procedure TWfxTreeBuilder.AddLinkTarget(aFile: TFile; CurrentNode: TFileTreeNode);

View file

@ -112,7 +112,7 @@ uses
//DC
fOptionsPluginsDSX, fOptionsPluginsWCX, fOptionsPluginsWDX,
fOptionsPluginsWFX, fOptionsPluginsWLX, WcxPlugin, uDCUtils, uLng,
uSpecialDir;
uSpecialDir, uWfxPluginUtil;
function ShowTweakPluginDlg(PluginType: TPluginType; PluginIndex: Integer): Boolean;
var
@ -215,7 +215,7 @@ begin
ptWFX:
begin
tmpWFXPlugins.FileName[PluginIndex]:= fnePlugin2.Text;
tmpWFXPlugins.Name[PluginIndex]:= edtName.Text;
tmpWFXPlugins.Name[PluginIndex]:= RepairPluginName(edtName.Text);
end;
ptWLX:
begin

View file

@ -882,7 +882,7 @@ begin
Assert(Assigned(pcRootName));
try
FsGetDefRootName(pcRootName, MAX_PATH);
Result := StrPas(pcRootName);
Result := RepairPluginName(StrPas(pcRootName));
finally
FreeMem(pcRootName);
end;
@ -964,7 +964,7 @@ begin
begin
if AConfig.TryGetValue(ANode, 'Name', AName) and AConfig.TryGetValue(ANode, 'Path', APath) then
begin
I := Add(AName, APath);
I := Add(RepairPluginName(AName), APath);
Enabled[I] := AConfig.GetAttr(ANode, 'Enabled', True);
end;
end;