diff options
author | Teravus Ovares | 2008-05-17 18:37:51 +0000 |
---|---|---|
committer | Teravus Ovares | 2008-05-17 18:37:51 +0000 |
commit | 6bcb0e8685c116702637c9dfe2e7ce3314eb4388 (patch) | |
tree | bc482f1ef56b6201ce33cab1e7cf5e644100361d /OpenSim/Region | |
parent | Thank you very much KMeisthax for DataSnapshot 1.1 (diff) | |
download | opensim-SC_OLD-6bcb0e8685c116702637c9dfe2e7ce3314eb4388.zip opensim-SC_OLD-6bcb0e8685c116702637c9dfe2e7ce3314eb4388.tar.gz opensim-SC_OLD-6bcb0e8685c116702637c9dfe2e7ce3314eb4388.tar.bz2 opensim-SC_OLD-6bcb0e8685c116702637c9dfe2e7ce3314eb4388.tar.xz |
* Update on the script engine LSL parser. Blocks all static objects and method references.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 58 |
1 files changed, 50 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 1832864..b5eabc1 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | |||
@@ -39,7 +39,15 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
39 | //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); | 39 | //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); |
40 | private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); | 40 | private Dictionary<string, string> dataTypes = new Dictionary<string, string>(); |
41 | private Dictionary<string, string> quotes = new Dictionary<string, string>(); | 41 | private Dictionary<string, string> quotes = new Dictionary<string, string>(); |
42 | // c Style | ||
43 | private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline); | ||
44 | // c# one liners | ||
45 | private Regex conelinecomments = new Regex(@".?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline); | ||
46 | // ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"]) | ||
47 | |||
42 | 48 | ||
49 | |||
50 | // value we're looking for: (?:[a-zA-Z])\.[a-zA-Z] | ||
43 | public LSL2CSConverter() | 51 | public LSL2CSConverter() |
44 | { | 52 | { |
45 | // Only the types we need to convert | 53 | // Only the types we need to convert |
@@ -81,17 +89,51 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
81 | bool last_was_escape = false; | 89 | bool last_was_escape = false; |
82 | int quote_replaced_count = 0; | 90 | int quote_replaced_count = 0; |
83 | 91 | ||
84 | string[] blocked = new string[] {"Axiom","Db4objects","libsecondlife","log4net","Microsoft", | 92 | |
85 | "Modified","Mono","MonoXnaCompactMaths","mscorlib","MySql", | 93 | |
86 | "NHibernate","Nini","nunit","Ode","OpenSim","PhysX_Wrapper_Dotnet", | 94 | string removecomments = conelinecomments.Replace(Script, ""); |
87 | "PumaCode","RAIL","XMLRPC","System"}; | 95 | removecomments = cstylecomments.Replace(removecomments, ""); |
96 | string[] localscript = removecomments.Split('"'); | ||
97 | string checkscript = String.Empty; | ||
98 | bool flip = true; | ||
88 | 99 | ||
89 | for (int p = 0; p < blocked.Length;p++) | 100 | |
101 | |||
102 | for (int p = 0; p < localscript.Length; p++) | ||
90 | { | 103 | { |
91 | Match SecurityM = Regex.Match(Script, "[;}][^\"']+" + blocked[p].Replace(".", "\\.") + "\\.[^\"']", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | 104 | if (localscript[p].Length >= 1) |
92 | if (SecurityM.Success) | 105 | { |
93 | throw new Exception("CS0103: 'The name '" + blocked[p] + "' does not exist in the current context'"); | 106 | if (localscript[p].Substring(localscript[p].Length - 1, 1) != "/") |
107 | { | ||
108 | flip = !flip; | ||
109 | } | ||
110 | } | ||
111 | else | ||
112 | { | ||
113 | flip = !flip; | ||
114 | } | ||
115 | if (!flip) | ||
116 | checkscript += "\"" + localscript[p]; | ||
94 | } | 117 | } |
118 | |||
119 | //System.Console.WriteLine("SCRIPT:" + checkscript); | ||
120 | |||
121 | // checks for alpha.alpha way of referring to objects in C# | ||
122 | // ignores alpha.x alpha.y, alpha.z for refering to vector components | ||
123 | Match SecurityM = Regex.Match(checkscript, @"(?:[a-zA-Z])\.(?:[a-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
124 | if (SecurityM.Success) | ||
125 | throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'"); | ||
126 | |||
127 | SecurityM = Regex.Match(checkscript, @"typeof\s", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
128 | if (SecurityM.Success) | ||
129 | throw new Exception("CS0103: 'The object.typeof method isn't allowed in LSL'"); | ||
130 | |||
131 | SecurityM = Regex.Match(checkscript, @"GetType\(", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); | ||
132 | if (SecurityM.Success) | ||
133 | throw new Exception("CS0103: 'The object.GetType method isn't allowed in LSL'"); | ||
134 | |||
135 | |||
136 | |||
95 | 137 | ||
96 | for (int p = 0; p < Script.Length; p++) | 138 | for (int p = 0; p < Script.Length; p++) |
97 | { | 139 | { |