From 5b159e957a441d37c4b5a2755964c3011aa492ec Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Sat, 21 Jun 2008 23:17:15 +0000 Subject: Mantis#1580. Thank you kindly, Dmiles for a patch that: solves an incorectly spliting and rejoining the passed in string[] cmdArgs and losing the double quoted separation of command arguments. --- OpenSim/Region/Application/OpenSim.cs | 47 ++++++++++++++++++++++++----------- 1 file changed, 32 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/Application') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index fa50bdc..4e69b9e 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -190,7 +190,7 @@ namespace OpenSim public override void RunCmd(string command, string[] cmdparams) { base.RunCmd(command, cmdparams); - RunPluginCommands(command + " " + CombineParams(cmdparams, 0)); + RunPluginCommands(command , cmdparams); switch (command) { case "clear-assets": @@ -691,10 +691,11 @@ namespace OpenSim /// /// returns true if a match was found, false otherwise. /// - public bool RunPluginCommands(string cmdWithParams) + public bool RunPluginCommands(string cmd, string[] withParams) { ConsolePluginCommand bestMatch = null; int bestLength = 0; + String cmdWithParams = cmd + " " + String.Join(" ",withParams); foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos) { int matchLen = cmdinfo.matchLength(cmdWithParams); @@ -705,7 +706,7 @@ namespace OpenSim } } if (bestMatch == null) return false; - bestMatch.Run(cmdWithParams.Substring(bestLength)); + bestMatch.Run(cmd,withParams);//.Substring(bestLength)); return true; } @@ -759,7 +760,7 @@ namespace OpenSim /// /// command in the form of "showme new commands" /// - private string m_cmdText; + private string[] m_cmdText; /// /// Construct a new ConsolePluginCommand @@ -772,7 +773,7 @@ namespace OpenSim /// the text displayed in "help showme new commands" public ConsolePluginCommand(string command, ConsoleCommand dlg, string help) { - m_cmdText = command; + m_cmdText = command.Split(new char[] { ' ' }); m_commandDelegate = dlg; m_helpText = help; } @@ -790,7 +791,7 @@ namespace OpenSim { // QUESTION: have a case insensitive flag? cmdWithParams = cmdWithParams.ToLower().Trim(); - string matchText = m_cmdText.ToLower().Trim(); + string matchText = String.Join(" ",m_cmdText).ToLower().Trim(); if (cmdWithParams.StartsWith(matchText)) { // QUESTION Instead return cmdText.Length; ? @@ -800,17 +801,33 @@ namespace OpenSim } /// - /// Run the delegate the incomming string may contain the command, if so, it is chopped off + /// Run the delegate the incomming string may contain the command, if so, it is chopped off the cmdParams[] /// - public void Run(string cmdParams) + public void Run(string cmd, string[] cmdParams) { - string targetText = m_cmdText.ToLower(); - string matchText = cmdParams.ToLower(); - if (targetText.StartsWith(matchText)) + int skipParams = 0; + if (m_cmdText.Length > 1) { - cmdParams = cmdParams.Substring(matchText.Length); + int currentParam = 1; + while (currentParam < m_cmdText.Length) + { + if (cmdParams[skipParams].ToLower().Equals(m_cmdText[currentParam].ToLower())) + { + skipParams++; + } + currentParam++; + } + + } + string[] sendCmdParams = cmdParams; + if (skipParams > 0) + { + sendCmdParams = new string[cmdParams.Length-skipParams]; + for (int i=0;i @@ -818,7 +835,7 @@ namespace OpenSim /// public void ShowHelp(ConsoleBase console) { - console.Notice(m_cmdText + " - " + m_helpText); + console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText); } /// @@ -827,7 +844,7 @@ namespace OpenSim public bool IsHelpfull(string cmdWithParams) { cmdWithParams = cmdWithParams.ToLower(); - return cmdWithParams.Contains(m_cmdText.ToLower()) || m_helpText.ToLower().Contains(cmdWithParams); + return cmdWithParams.Contains(String.Join(" ", m_cmdText).ToLower()) || m_helpText.ToLower().Contains(cmdWithParams); } } -- cgit v1.1