Skip to content

Commit 560bb6d

Browse files
authored
Merge pull request #618 from git-for-windows/test-custom-editor-on-writable-file
installer: test any custom editor on a _writable_ file
2 parents 8cfa119 + 152f1a9 commit 560bb6d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

installer/install.iss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1731,7 +1731,10 @@ begin
17311731
Exit;
17321732
end;
17331733
1734-
TmpFile:=ExpandConstant('{tmp}\editor-test.txt');
1734+
// We are _not_ writing into the `{tmp}` directory, because it is private to the
1735+
// elevated process and cannot be written to by the non-elevated editor.
1736+
// Instead, we write _next_ to the `{tmp}` directory.
1737+
TmpFile:=ExpandConstant('{tmp}-editor-test.txt');
17351738
InputText:='Please modify this text, e.g. delete it, then save it and exit the editor.'
17361739
SaveStringToFile(TmpFile,InputText,False);
17371740
@@ -1744,17 +1747,20 @@ begin
17441747
if not ShellExecAsOriginalUser('',CustomEditorPath,CustomEditorOptions+' "'+TmpFile+'"','',Show,ewWaitUntilTerminated,Res) then begin
17451748
Wizardform.NextButton.Enabled:=False;
17461749
SuppressibleMsgBox('Could not launch: "'+CustomEditorPath+'"',mbError,MB_OK,IDOK);
1750+
DeleteFile(TmpFile); // ignore errors, if any
17471751
Exit;
17481752
end;
17491753
if (Res<>0) then begin
17501754
Wizardform.NextButton.Enabled:=False;
17511755
SuppressibleMsgBox('Exited with failure: "'+CustomEditorPath+'"',mbError,MB_OK,IDOK);
1756+
DeleteFile(TmpFile); // ignore errors, if any
17521757
Exit;
17531758
end;
17541759
17551760
if not LoadStringFromFile(TmpFile,OutputText) then begin
17561761
Wizardform.NextButton.Enabled:=False;
17571762
SuppressibleMsgBox('Could not read "'+TmpFile+'"',mbError,MB_OK,IDOK);
1763+
DeleteFile(TmpFile); // ignore errors, if any
17581764
Exit;
17591765
end;
17601766

0 commit comments

Comments
 (0)