浏览代码

Allow empty ISSigUrl for automatic handling.

Martijn Laan 3 月之前
父节点
当前提交
12357a3acf

+ 3 - 6
Examples/CodeDownloadFiles.iss

@@ -72,17 +72,14 @@ begin
     DownloadPage.Clear;
     DownloadPage.Clear;
     // Use AddEx or AddExWithISSigVerify to specify a username and password
     // Use AddEx or AddExWithISSigVerify to specify a username and password
     DownloadPage.AddWithISSigVerify(
     DownloadPage.AddWithISSigVerify(
-      'https://jrsoftware.org/download.php/is.exe?dontcount=1',
-      'https://jrsoftware.org/download.php/is.exe.issig',
+      'https://jrsoftware.org/download.php/is.exe?dontcount=1', '',
       'innosetup-latest.exe', AllowedKeysRuntimeIDs);
       'innosetup-latest.exe', AllowedKeysRuntimeIDs);
     DownloadPage.AddWithISSigVerify(
     DownloadPage.AddWithISSigVerify(
-      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z',
-      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z.issig',
+      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
       'MyProg-ExtraReadmes.7z', AllowedKeysRuntimeIDs);
       'MyProg-ExtraReadmes.7z', AllowedKeysRuntimeIDs);
     DownloadPage.Add(
     DownloadPage.Add(
       'https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1',
       'https://jrsoftware.org/download.php/iscrypt.dll?dontcount=1',
-      'ISCrypt.dll',
-      '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
+      'ISCrypt.dll', '2f6294f9aa09f59a574b5dcd33be54e16b39377984f3d5658cda44950fa0f8fc');
     DownloadPage.Show;
     DownloadPage.Show;
     try
     try
       try
       try

+ 2 - 2
ISHelp/isxfunc.xml

@@ -1862,6 +1862,7 @@ end;</pre>
         <name>DownloadTemporaryFileWithISSigVerify</name>
         <name>DownloadTemporaryFileWithISSigVerify</name>
         <prototype>function DownloadTemporaryFileWithISSigVerify(const Url, ISSigUrl, BaseName: String; const AllowedKeysRuntimeIDs: TStringList; const OnDownloadProgress: TOnDownloadProgress): Int64;</prototype>
         <prototype>function DownloadTemporaryFileWithISSigVerify(const Url, ISSigUrl, BaseName: String; const AllowedKeysRuntimeIDs: TStringList; const OnDownloadProgress: TOnDownloadProgress): Int64;</prototype>
         <description><p>Like <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link>, but downloads an .issig signature file first from the specified second URL and uses it to verify the main file downloaded from the first URL.</p>
         <description><p>Like <link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link>, but downloads an .issig signature file first from the specified second URL and uses it to verify the main file downloaded from the first URL.</p>
+<p>If the second URL is an empty string, Setup will instead append ".issig" (without quotes) to the path portion of the first URL and use the result as the URL to download the .issig signature file from.</p>        
 <p>Verification uses the specified allowed keys, looked up using <link topic="issigkeyssection">[ISSigKeys] section</link> parameter <tt>RuntimeID</tt>. To allow all keys set AllowedKeysRuntimeIDs to <tt>nil</tt>.</p>
 <p>Verification uses the specified allowed keys, looked up using <link topic="issigkeyssection">[ISSigKeys] section</link> parameter <tt>RuntimeID</tt>. To allow all keys set AllowedKeysRuntimeIDs to <tt>nil</tt>.</p>
 <p>An exception will be raised if there was an error. Otherwise, returns the number of bytes downloaded for the main file from the first URL. Returns 0 if the main file was already downloaded and still verified.</p></description>
 <p>An exception will be raised if there was an error. Otherwise, returns the number of bytes downloaded for the main file from the first URL. Returns 0 if the main file was already downloaded and still verified.</p></description>
         <seealso><p><link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br/>
         <seealso><p><link topic="isxfunc_DownloadTemporaryFile">DownloadTemporaryFile</link><br/>
@@ -1873,8 +1874,7 @@ function InitializeSetup: Boolean;
 begin
 begin
   try
   try
     DownloadTemporaryFileWithISSigVerify(
     DownloadTemporaryFileWithISSigVerify(
-      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z',
-      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z.issig',
+      'https://jrsoftware.org/download.php/myprog-extrareadmes.7z', '',
       'myprog-extrareadmes.7z', nil, nil);
       'myprog-extrareadmes.7z', nil, nil);
     Result := True;
     Result := True;
   except
   except

+ 13 - 3
Projects/Src/Setup.Install.pas

@@ -35,6 +35,7 @@ function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String
 function DownloadTemporaryFileSize(const Url: String): Int64;
 function DownloadTemporaryFileSize(const Url: String): Int64;
 function DownloadTemporaryFileDate(const Url: String): String;
 function DownloadTemporaryFileDate(const Url: String): String;
 procedure SetDownloadCredentials(const User, Pass: String);
 procedure SetDownloadCredentials(const User, Pass: String);
+function GetISSigUrl(const Url, ISSigUrl: String): String;
 
 
 implementation
 implementation
 
 
@@ -3669,10 +3670,8 @@ begin
 end;
 end;
 
 
 function GetCredentialsAndCleanUrl(const Url: String; var User, Pass, CleanUrl: String) : Boolean;
 function GetCredentialsAndCleanUrl(const Url: String; var User, Pass, CleanUrl: String) : Boolean;
-var
-  Uri: TUri;
 begin
 begin
-  Uri := TUri.Create(Url);
+  const Uri = TUri.Create(Url); { This is a record so no need to free }
   if DownloadUser = '' then
   if DownloadUser = '' then
     User := TNetEncoding.URL.Decode(Uri.Username)
     User := TNetEncoding.URL.Decode(Uri.Username)
   else
   else
@@ -3691,6 +3690,17 @@ begin
     Log('Download is not using basic authentication');
     Log('Download is not using basic authentication');
 end;
 end;
 
 
+function GetISSigUrl(const Url, ISSigUrl: String): String;
+begin
+  if ISSigUrl <> '' then
+    Result := ISSigUrl
+  else begin
+    const Uri = TUri.Create(Url); { This is a record so no need to free }
+    Uri.Path := TNetEncoding.URL.Decode(Uri.Path) + ISSigExt;
+    Result := Uri.ToString;
+  end;
+end;
+
 function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String;
 function DownloadTemporaryFile(const Url, BaseName, RequiredSHA256OfFile: String;
   const ISSigVerify: Boolean; const ISSigAllowedKeys: AnsiString;
   const ISSigVerify: Boolean; const ISSigAllowedKeys: AnsiString;
   const OnDownloadProgress: TOnDownloadProgress): Int64;
   const OnDownloadProgress: TOnDownloadProgress): Int64;

+ 1 - 1
Projects/Src/Setup.ScriptDlg.pas

@@ -1115,7 +1115,7 @@ function TDownloadWizardPage.AddExWithISSigVerify(const Url, ISSigUrl, BaseName,
 begin
 begin
   { Also see Setup.ScriptFunc DownloadTemporaryFileWithISSigVerify }
   { Also see Setup.ScriptFunc DownloadTemporaryFileWithISSigVerify }
   const ISSigAllowedKeys = ConvertAllowedKeysRuntimeIDsToISSigAllowedKeys(AllowedKeysRuntimeIDs);
   const ISSigAllowedKeys = ConvertAllowedKeysRuntimeIDsToISSigAllowedKeys(AllowedKeysRuntimeIDs);
-  DoAdd(ISSigUrl, BaseName + ISSigExt, '', UserName, Password, False, '');
+  DoAdd(GetISSigUrl(Url, ISSigUrl), BaseName + ISSigExt, '', UserName, Password, False, '');
   Result := DoAdd(Url, BaseName, '', UserName, Password, True, ISSigAllowedKeys);
   Result := DoAdd(Url, BaseName, '', UserName, Password, True, ISSigAllowedKeys);
 end;
 end;
 
 

+ 1 - 1
Projects/Src/Setup.ScriptFunc.pas

@@ -824,7 +824,7 @@ var
 
 
       { Also see Setup.ScriptDlg TDownloadWizardPage.AddExWithISSigVerify }
       { Also see Setup.ScriptDlg TDownloadWizardPage.AddExWithISSigVerify }
       if ISSigVerify then
       if ISSigVerify then
-        DownloadTemporaryFile(ISSigUrl, BaseName + ISSigExt, '', False, '', OnDownloadProgress);
+        DownloadTemporaryFile(GetISSigUrl(Url, ISSigUrl), BaseName + ISSigExt, '', False, '', OnDownloadProgress);
       Stack.SetInt64(PStart, DownloadTemporaryFile(Url, BaseName, RequiredSHA256OfFile, ISSigVerify, ISSigAllowedKeys, OnDownloadProgress));
       Stack.SetInt64(PStart, DownloadTemporaryFile(Url, BaseName, RequiredSHA256OfFile, ISSigVerify, ISSigAllowedKeys, OnDownloadProgress));
     end);
     end);
     RegisterScriptFunc('DownloadTemporaryFileSize', sfNoUninstall, procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)
     RegisterScriptFunc('DownloadTemporaryFileSize', sfNoUninstall, procedure(const Caller: TPSExec; const OrgName: AnsiString; const Stack: TPSStack; const PStart: Cardinal)