Просмотр исходного кода

Bug 2134: Set $PSNativeCommandArgumentPassing to "Legacy" in generated WinSCP scripting PowerShell commandline, which is needed for PowerShell 7.3 compatibility

https://winscp.net/tracker/2134

Source commit: 037d91a5f3eeb5113fb137c0432167d55eccdc4c
Martin Prikryl 2 лет назад
Родитель
Сommit
7af5fa85d8
3 измененных файлов с 16 добавлено и 1 удалено
  1. 14 1
      source/forms/GenerateUrl.cpp
  2. 1 0
      source/resource/TextsWin.h
  3. 1 0
      source/resource/TextsWin1.rc

+ 14 - 1
source/forms/GenerateUrl.cpp

@@ -86,7 +86,14 @@ void __fastcall TRichEditWithLinks::Dispatch(void * AMessage)
         if (DebugAlwaysTrue(ENLink.chrg.cpMax < AText.Length()))
         {
           UnicodeString Url = AText.SubString(ENLink.chrg.cpMin + 1, ENLink.chrg.cpMax - ENLink.chrg.cpMin);
-          ShowHelp(Url);
+          if (IsHttpOrHttpsUrl(Url))
+          {
+            OpenBrowser(Url);
+          }
+          else
+          {
+            ShowHelp(Url);
+          }
         }
       }
     }
@@ -461,7 +468,13 @@ UnicodeString __fastcall TGenerateUrlDialog::GenerateScript(UnicodeString & Scri
   }
   else if (ScriptFormatCombo->ItemIndex == sfPowerShell)
   {
+    // https://stackoverflow.com/q/74440303/850848
+    UnicodeString PsArgPassingLink(L"https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_preference_variables#psnativecommandargumentpassing");
+
     Result =
+      RtfLink(PsArgPassingLink, RtfScriptComment(FORMAT(L"# %s", (LoadStr(GENERATE_URL_PS_ARG_PASSING))))) + RtfPara +
+      RtfLink(PsArgPassingLink, L"$PSNativeCommandArgumentPassing") + L" = " + AssemblyString(alPowerShell, L"Legacy") + RtfPara +
+      RtfPara +
       RtfText(L"& \"" + ComExeName + "\" `") + RtfPara +
       RtfText(L"  ") + LogParameter + L" " + IniParameter + RtfText(L" `") + RtfPara +
       RtfText(L"  ") + CommandParameter;

+ 1 - 0
source/resource/TextsWin.h

@@ -665,6 +665,7 @@
 #define PROPERTIES_S3_R_ACL_HINT 6050
 #define PROPERTIES_S3_W_ACL_HINT 6051
 #define LOGIN_S3_GENERAL_CREDENTIALS 6052
+#define GENERATE_URL_PS_ARG_PASSING 6053
 
 // 2xxx is reserved for TextsFileZilla.h
 

+ 1 - 0
source/resource/TextsWin1.rc

@@ -670,6 +670,7 @@ BEGIN
         PROPERTIES_S3_R_ACL_HINT, "Read ACL"
         PROPERTIES_S3_W_ACL_HINT, "Write ACL"
         LOGIN_S3_GENERAL_CREDENTIALS, "General"
+        GENERATE_URL_PS_ARG_PASSING, "Needed for PowerShell 7.3 and newer"
 
         WIN_VARIABLE_STRINGS, "WIN_VARIABLE"
         WINSCP_COPYRIGHT, "Copyright © 2000–2022 Martin Prikryl"