aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorTeravus Ovares2008-05-28 01:47:33 +0000
committerTeravus Ovares2008-05-28 01:47:33 +0000
commitfb1c7e62d260d15926d727fa27d87257160f0d10 (patch)
tree1a575bae4b5523e1568d5a3b8a9d43c1a551d007 /OpenSim
parentChange a couple Windows directory separators in SVN module to be platform agn... (diff)
downloadopensim-SC_OLD-fb1c7e62d260d15926d727fa27d87257160f0d10.zip
opensim-SC_OLD-fb1c7e62d260d15926d727fa27d87257160f0d10.tar.gz
opensim-SC_OLD-fb1c7e62d260d15926d727fa27d87257160f0d10.tar.bz2
opensim-SC_OLD-fb1c7e62d260d15926d727fa27d87257160f0d10.tar.xz
* Resolves comment removal in string literals in the LSL2CSConverter
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs36
1 files changed, 19 insertions, 17 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index 5d51898..a40b95b 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
@@ -42,7 +42,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
42 // c Style 42 // c Style
43 private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline); 43 private Regex cstylecomments = new Regex(@"/\*(.|[\r\n])*?\*/", RegexOptions.Compiled | RegexOptions.Multiline);
44 // c# one liners 44 // c# one liners
45 private Regex conelinecomments = new Regex(@".?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline); 45 private Regex nonCommentFwsl = new Regex("\"[a-zA-Z0-9.,:/ ]+//[^\"]+(" + @"[\\" + "\"]+)?[\"](\\s+)?;", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
46 private Regex conelinecomments = new Regex(@"[^:].?([\/]{2}[^\n]*)|([\n]{1,}[\/]{2}[^\n]*)", RegexOptions.Compiled | RegexOptions.Multiline);
46 // ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"]) 47 // ([^\"])((?:[a-zA-Z])\.[a-zA-Z].?)([^\"])
47 48
48 // value we're looking for: (?:[a-zA-Z])\.[a-zA-Z] 49 // value we're looking for: (?:[a-zA-Z])\.[a-zA-Z]
@@ -86,8 +87,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
86 string quote = String.Empty; 87 string quote = String.Empty;
87 bool last_was_escape = false; 88 bool last_was_escape = false;
88 int quote_replaced_count = 0; 89 int quote_replaced_count = 0;
89 90
90 string removecomments = conelinecomments.Replace(Script, ""); 91 string removefwnoncomments = nonCommentFwsl.Replace(Script, "\"\";");
92
93 string removecomments = conelinecomments.Replace(removefwnoncomments, "");
91 removecomments = cstylecomments.Replace(removecomments, ""); 94 removecomments = cstylecomments.Replace(removecomments, "");
92 string[] localscript = removecomments.Split('"'); 95 string[] localscript = removecomments.Split('"');
93 string checkscript = String.Empty; 96 string checkscript = String.Empty;
@@ -95,19 +98,21 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
95 98
96 for (int p = 0; p < localscript.Length; p++) 99 for (int p = 0; p < localscript.Length; p++)
97 { 100 {
98 if (localscript[p].Length >= 1) 101 //if (localscript[p].Length >= 1)
99 { 102 //{
100 if (localscript[p].Substring(localscript[p].Length - 1, 1) != @"\") 103 if (!localscript[p].EndsWith(@"\"))
101 { 104 {
102 flip = !flip; 105 flip = !flip;
106 //System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p] + " ! " + localscript[p].EndsWith(@"\").ToString());
103 } 107 }
104 } 108 //}
105 else 109 //else
106 { 110 //{
107 flip = !flip; 111 // flip = !flip;
108 } 112 // System.Console.WriteLine("Flip:" + flip.ToString() + " - " + localscript[p]);
113 //}
109 if (!flip) 114 if (!flip)
110 checkscript += "\"" + localscript[p]; 115 checkscript += localscript[p];
111 } 116 }
112 117
113 //System.Console.WriteLine("SCRIPT:" + checkscript); 118 //System.Console.WriteLine("SCRIPT:" + checkscript);
@@ -116,11 +121,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
116 // ignores alpha.x alpha.y, alpha.z for refering to vector components 121 // ignores alpha.x alpha.y, alpha.z for refering to vector components
117 Match SecurityM; 122 Match SecurityM;
118 123
119 // Instead of blocking all foo.bar values, block only the ones that will hit 124 // BROKEN: this check is very wrong. It block's any url in strings.
120 // namespaces we don't like. To add more of these bad namespaces at them 125 SecurityM = Regex.Match(checkscript, @"(?:[a-zA-Z])\.(?:[a-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
121 // to the poison array.
122 String[] poison = {"System"};
123 SecurityM = Regex.Match(checkscript, @"(" + String.Join("|", poison) + @")\.(?:[a-wA-Z]|[a-zA-Z][a-zA-Z])", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline);
124 if (SecurityM.Success) 126 if (SecurityM.Success)
125 throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'"); 127 throw new Exception("CS0103: 'The . symbol cannot be used in LSL except in float values or vector components'");
126 128