diff options
author | Charles Krinke | 2008-06-21 23:17:15 +0000 |
---|---|---|
committer | Charles Krinke | 2008-06-21 23:17:15 +0000 |
commit | 5b159e957a441d37c4b5a2755964c3011aa492ec (patch) | |
tree | ea1f582758331003c80eb324f3cde7965d174167 /OpenSim/Region/Application/OpenSim.cs | |
parent | * refactor: Making some of the serialization names consistent, both within th... (diff) | |
download | opensim-SC_OLD-5b159e957a441d37c4b5a2755964c3011aa492ec.zip opensim-SC_OLD-5b159e957a441d37c4b5a2755964c3011aa492ec.tar.gz opensim-SC_OLD-5b159e957a441d37c4b5a2755964c3011aa492ec.tar.bz2 opensim-SC_OLD-5b159e957a441d37c4b5a2755964c3011aa492ec.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/Application/OpenSim.cs')
-rw-r--r-- | OpenSim/Region/Application/OpenSim.cs | 47 |
1 files changed, 32 insertions, 15 deletions
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 | |||
190 | public override void RunCmd(string command, string[] cmdparams) | 190 | public override void RunCmd(string command, string[] cmdparams) |
191 | { | 191 | { |
192 | base.RunCmd(command, cmdparams); | 192 | base.RunCmd(command, cmdparams); |
193 | RunPluginCommands(command + " " + CombineParams(cmdparams, 0)); | 193 | RunPluginCommands(command , cmdparams); |
194 | switch (command) | 194 | switch (command) |
195 | { | 195 | { |
196 | case "clear-assets": | 196 | case "clear-assets": |
@@ -691,10 +691,11 @@ namespace OpenSim | |||
691 | /// | 691 | /// |
692 | /// returns true if a match was found, false otherwise. | 692 | /// returns true if a match was found, false otherwise. |
693 | /// </summary> | 693 | /// </summary> |
694 | public bool RunPluginCommands(string cmdWithParams) | 694 | public bool RunPluginCommands(string cmd, string[] withParams) |
695 | { | 695 | { |
696 | ConsolePluginCommand bestMatch = null; | 696 | ConsolePluginCommand bestMatch = null; |
697 | int bestLength = 0; | 697 | int bestLength = 0; |
698 | String cmdWithParams = cmd + " " + String.Join(" ",withParams); | ||
698 | foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos) | 699 | foreach (ConsolePluginCommand cmdinfo in m_PluginCommandInfos) |
699 | { | 700 | { |
700 | int matchLen = cmdinfo.matchLength(cmdWithParams); | 701 | int matchLen = cmdinfo.matchLength(cmdWithParams); |
@@ -705,7 +706,7 @@ namespace OpenSim | |||
705 | } | 706 | } |
706 | } | 707 | } |
707 | if (bestMatch == null) return false; | 708 | if (bestMatch == null) return false; |
708 | bestMatch.Run(cmdWithParams.Substring(bestLength)); | 709 | bestMatch.Run(cmd,withParams);//.Substring(bestLength)); |
709 | return true; | 710 | return true; |
710 | } | 711 | } |
711 | 712 | ||
@@ -759,7 +760,7 @@ namespace OpenSim | |||
759 | /// <summary> | 760 | /// <summary> |
760 | /// command in the form of "showme new commands" | 761 | /// command in the form of "showme new commands" |
761 | /// </summary> | 762 | /// </summary> |
762 | private string m_cmdText; | 763 | private string[] m_cmdText; |
763 | 764 | ||
764 | /// <summary> | 765 | /// <summary> |
765 | /// Construct a new ConsolePluginCommand | 766 | /// Construct a new ConsolePluginCommand |
@@ -772,7 +773,7 @@ namespace OpenSim | |||
772 | /// <param name="help">the text displayed in "help showme new commands"</param> | 773 | /// <param name="help">the text displayed in "help showme new commands"</param> |
773 | public ConsolePluginCommand(string command, ConsoleCommand dlg, string help) | 774 | public ConsolePluginCommand(string command, ConsoleCommand dlg, string help) |
774 | { | 775 | { |
775 | m_cmdText = command; | 776 | m_cmdText = command.Split(new char[] { ' ' }); |
776 | m_commandDelegate = dlg; | 777 | m_commandDelegate = dlg; |
777 | m_helpText = help; | 778 | m_helpText = help; |
778 | } | 779 | } |
@@ -790,7 +791,7 @@ namespace OpenSim | |||
790 | { | 791 | { |
791 | // QUESTION: have a case insensitive flag? | 792 | // QUESTION: have a case insensitive flag? |
792 | cmdWithParams = cmdWithParams.ToLower().Trim(); | 793 | cmdWithParams = cmdWithParams.ToLower().Trim(); |
793 | string matchText = m_cmdText.ToLower().Trim(); | 794 | string matchText = String.Join(" ",m_cmdText).ToLower().Trim(); |
794 | if (cmdWithParams.StartsWith(matchText)) | 795 | if (cmdWithParams.StartsWith(matchText)) |
795 | { | 796 | { |
796 | // QUESTION Instead return cmdText.Length; ? | 797 | // QUESTION Instead return cmdText.Length; ? |
@@ -800,17 +801,33 @@ namespace OpenSim | |||
800 | } | 801 | } |
801 | 802 | ||
802 | /// <summary> | 803 | /// <summary> |
803 | /// Run the delegate the incomming string may contain the command, if so, it is chopped off | 804 | /// Run the delegate the incomming string may contain the command, if so, it is chopped off the cmdParams[] |
804 | /// </summary> | 805 | /// </summary> |
805 | public void Run(string cmdParams) | 806 | public void Run(string cmd, string[] cmdParams) |
806 | { | 807 | { |
807 | string targetText = m_cmdText.ToLower(); | 808 | int skipParams = 0; |
808 | string matchText = cmdParams.ToLower(); | 809 | if (m_cmdText.Length > 1) |
809 | if (targetText.StartsWith(matchText)) | ||
810 | { | 810 | { |
811 | cmdParams = cmdParams.Substring(matchText.Length); | 811 | int currentParam = 1; |
812 | while (currentParam < m_cmdText.Length) | ||
813 | { | ||
814 | if (cmdParams[skipParams].ToLower().Equals(m_cmdText[currentParam].ToLower())) | ||
815 | { | ||
816 | skipParams++; | ||
817 | } | ||
818 | currentParam++; | ||
819 | } | ||
820 | |||
821 | } | ||
822 | string[] sendCmdParams = cmdParams; | ||
823 | if (skipParams > 0) | ||
824 | { | ||
825 | sendCmdParams = new string[cmdParams.Length-skipParams]; | ||
826 | for (int i=0;i<sendCmdParams.Length;i++) { | ||
827 | sendCmdParams[i] = cmdParams[skipParams++]; | ||
828 | } | ||
812 | } | 829 | } |
813 | m_commandDelegate(cmdParams.Trim().Split(new char[] { ' ' })); | 830 | m_commandDelegate(sendCmdParams);//.Trim().Split(new char[] { ' ' })); |
814 | } | 831 | } |
815 | 832 | ||
816 | /// <summary> | 833 | /// <summary> |
@@ -818,7 +835,7 @@ namespace OpenSim | |||
818 | /// </summary> | 835 | /// </summary> |
819 | public void ShowHelp(ConsoleBase console) | 836 | public void ShowHelp(ConsoleBase console) |
820 | { | 837 | { |
821 | console.Notice(m_cmdText + " - " + m_helpText); | 838 | console.Notice(String.Join(" ", m_cmdText) + " - " + m_helpText); |
822 | } | 839 | } |
823 | 840 | ||
824 | /// <summary> | 841 | /// <summary> |
@@ -827,7 +844,7 @@ namespace OpenSim | |||
827 | public bool IsHelpfull(string cmdWithParams) | 844 | public bool IsHelpfull(string cmdWithParams) |
828 | { | 845 | { |
829 | cmdWithParams = cmdWithParams.ToLower(); | 846 | cmdWithParams = cmdWithParams.ToLower(); |
830 | return cmdWithParams.Contains(m_cmdText.ToLower()) || m_helpText.ToLower().Contains(cmdWithParams); | 847 | return cmdWithParams.Contains(String.Join(" ", m_cmdText).ToLower()) || m_helpText.ToLower().Contains(cmdWithParams); |
831 | } | 848 | } |
832 | } | 849 | } |
833 | 850 | ||