浏览代码

Bug 2070: Misplaced warning about unused scripting parameters when /rawsettings command-line switch is used

https://winscp.net/tracker/2070

Source commit: 3bc1f2daf0747e7cd455637b15c2732ca45b0116
Martin Prikryl 3 年之前
父节点
当前提交
9a417c3079
共有 3 个文件被更改,包括 20 次插入1 次删除
  1. 10 0
      source/core/Option.cpp
  2. 1 0
      source/core/Option.h
  3. 9 1
      source/windows/ConsoleRunner.cpp

+ 10 - 0
source/core/Option.cpp

@@ -20,6 +20,16 @@ __fastcall TOptions::TOptions()
   FParamCount = 0;
 }
 //---------------------------------------------------------------------------
+__fastcall TOptions::TOptions(const TOptions & Source)
+{
+  FSwitchMarks = Source.FSwitchMarks;
+  FSwitchValueDelimiters = Source.FSwitchValueDelimiters;
+  FOptions = Source.FOptions;
+  FOriginalOptions = Source.FOriginalOptions;
+  FNoMoreSwitches = Source.FNoMoreSwitches;
+  FParamCount = Source.FParamCount;
+}
+//---------------------------------------------------------------------------
 void __fastcall TOptions::Parse(const UnicodeString & CmdLine)
 {
   UnicodeString ACmdLine = CmdLine;

+ 1 - 0
source/core/Option.h

@@ -12,6 +12,7 @@ class TOptions
 {
 public:
   __fastcall TOptions();
+  __fastcall TOptions(const TOptions & Source);
 
   void __fastcall Add(UnicodeString Option);
   void __fastcall Parse(const UnicodeString & CmdLine);

+ 9 - 1
source/windows/ConsoleRunner.cpp

@@ -2956,7 +2956,15 @@ int __fastcall Console(TConsoleMode Mode)
           Session = Params->Param[1];
           if (Params->ParamCount > 1)
           {
-            Runner->PrintMessage(LoadStr(SCRIPT_CMDLINE_PARAMETERS));
+            // Check if the pending parameters will be consumed by ParseUrl (/rawsettings) in TManagementScript::Connect.
+            // This way we parse the options twice, but we do not want to refactor the code just for nicer test for this minor warning.
+            TOptions OptionsCopy(*Params);
+            bool DefaultsOnly = false;
+            StoredSessions->ParseUrl(Session, &OptionsCopy, DefaultsOnly);
+            if (OptionsCopy.ParamCount > 1)
+            {
+              Runner->PrintMessage(LoadStr(SCRIPT_CMDLINE_PARAMETERS));
+            }
           }
         }