From: <br...@us...> - 2008-12-09 15:17:28
|
Revision: 439 http://acmcontester.svn.sourceforge.net/acmcontester/?rev=439&view=rev Author: brus07 Date: 2008-12-09 15:17:25 +0000 (Tue, 09 Dec 2008) Log Message: ----------- Read SecureLever from config file. Now source code can send with HtmlEntity, in this class it decode to normal chars. Modified Paths: -------------- ACMServer/trunk/ACMServer/Runner/Class1.cs Modified: ACMServer/trunk/ACMServer/Runner/Class1.cs =================================================================== --- ACMServer/trunk/ACMServer/Runner/Class1.cs 2008-12-08 11:06:24 UTC (rev 438) +++ ACMServer/trunk/ACMServer/Runner/Class1.cs 2008-12-09 15:17:25 UTC (rev 439) @@ -11,6 +11,18 @@ { public class Checker { + private static List<KeyValuePair<string, string>> htmlEntityList; + + private static string HtmlEntityDecode(string str) + { + InitHtmlEntityList(); + for (int i = 0; i < htmlEntityList.Count; i++) + { + str = str.Replace(htmlEntityList[i].Key, htmlEntityList[i].Value); + } + return str; + } + public static string GetResult(string message) { Log log = Log.GetLog(); @@ -18,9 +30,13 @@ log.Loging(message, Log.Priority.INFO); log.Loging("", Log.Priority.INFO); + IniFile iniFile = new IniFile("RealTesterConfig.ini"); + string secureLever = iniFile.GetString("MainConfig", "SecureLevel", "Double"); + //TODO: Submit submit = Submit.CreateFromXml(message); string code = submit.sourceCode; + code = HtmlEntityDecode(code); string id = submit.id.ToString(); Result result = new Result(submit); @@ -51,7 +67,17 @@ if (test.comp.Result == Test.CompRes.OK) { - test.RunAllTests(SecureType.Double); + SecureType secureType = SecureType.Double; + try + { + secureType = (SecureType)Enum.Parse(typeof(SecureType), secureLever, true); + } + catch (ArgumentException) + { + } + if (secureLever == "None") + secureType = SecureType.None; + test.RunAllTests(secureType); for (int i = 0; i < test.run.results.Length; i++) { @@ -97,5 +123,21 @@ } return result.ToStringX(); } + + + private static void InitHtmlEntityList() + { + if (htmlEntityList != null) + return; + htmlEntityList = new List<KeyValuePair<string,string>>(); + AddElementToHtmlEntityList("\"", """); + AddElementToHtmlEntityList("<", "<"); + AddElementToHtmlEntityList("&", "&"); + } + + private static void AddElementToHtmlEntityList(string p, string p_2) + { + htmlEntityList.Add(new KeyValuePair<string, string>(p, p_2)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |