public void Load() { string[] code = Main.Properties.Settings.Default.ChatSave.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); foreach (var x in code) { string[] pp = x.Split(','); int id = int.Parse(pp[0]); foreach (var s in TwoRatChat.Main.Sources.SourceManager.Sources) { if (s.Id == id) { AddSource(s, pp[1], pp[2]); break; } } } //code = Main.Properties.Settings.Default.voice_Personals.Split( new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries ); //foreach( var x in code ) { // string[] pp = x.Trim( ' ', '\r', '\n', '\t' ).Split( ',' ); // PersonalData pd = new Main.Model.PersonalData(); // pd.VoiceHello = pp[1]; // if( pp.Length > 2 ) // pd.CustomIcon = pp[2]; // PersonalData[pp[0]] = pd; //} //PersonalData["TwoRatChat"] = new Main.Model.PersonalData() { VoiceHello = "", CustomIcon = "" }; BlackList.Load(Main.Properties.Settings.Default.Chat_Blacklist); ImageBlackList.Load(Main.Properties.Settings.Default.imageBlackList); ImageWhiteList.Load(Main.Properties.Settings.Default.imageWhiteList); // this._LevelManager.Load(); }
public void Save() { // this._LevelManager.Save(); StringBuilder sb = new StringBuilder(); foreach (var s in _sources) { sb.AppendFormat("{0},{1},{2};", s.SystemId, s.Uri, s.Label); } Main.Properties.Settings.Default.ChatSave = sb.ToString(); Main.Properties.Settings.Default.Chat_Blacklist = BlackList.Save(); Main.Properties.Settings.Default.imageBlackList = ImageBlackList.Save(); Main.Properties.Settings.Default.imageWhiteList = ImageWhiteList.Save(); this.CustomUsers.Save(); //sb.Clear(); //foreach ( var pd in PersonalData ) // sb.AppendFormat( "{0},{1},{2};", pd.Key, pd.Value.VoiceHello, pd.Value.CustomIcon ); //Main.Properties.Settings.Default.voice_Personals = sb.ToString(); }
/// <summary> /// Checks that the file extension is in the white-list. /// </summary> /// <param name="fileName">The file name.</param> /// <param name="expectedType">image, xml, or null</param> public static bool CheckFileExtensionIsValid(string fileName, string expectedType) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentNullException(nameof(fileName)); } string checkExt = Path.GetExtension(fileName); if (string.IsNullOrEmpty(checkExt)) { return(false); } // Check against blacklist // (Since the whitelist is configurable, back it up with an additional black-list check) checkExt = checkExt.ToLowerInvariant( ); if (BlackListExtensions.Contains(checkExt)) { EventLog.Application.WriteWarning($"File upload blocked by system due to file extension: {fileName}"); return(false); } // Check purpose-specific whitelist if (expectedType == "image") { bool allowed = ImageWhiteList.Contains(checkExt); return(allowed); } if (expectedType == "import") { bool allowed = ImportWhiteList.Contains(checkExt); return(allowed); } if (expectedType == "xml") { bool allowed = checkExt == ".xml"; return(allowed); } // Check tenant document whitelist IEnumerable <DocumentType> docTypes = Entity.GetInstancesOfType <DocumentType>(false, "extension, isOfType.id"); foreach (DocumentType docType in docTypes) { string extensions = docType.Extension; if (string.IsNullOrEmpty(extensions)) { continue; } string[] extList = extensions.Split(';'); foreach (string ext in extList) { string curExt = Path.GetExtension(ext.Trim()); if (string.Compare(checkExt, curExt, StringComparison.OrdinalIgnoreCase) == 0) { return(true); } } } EventLog.Application.WriteWarning($"File upload blocked by whitelist due to file extension: {fileName}"); return(false); }
private void onMessage(ChatMessage m) { if (Main.Properties.Settings.Default.showImageMode > 0) { bool allow = false; switch (Main.Properties.Settings.Default.showImageMode) { case 5: allow = true; break; case 4: if (!ImageBlackList.IsInList(m.Source, m.Name)) { allow = true; } break; case 3: if (ImageWhiteList.IsInList(m.Source, m.Name)) { allow = true; } break; } if (allow) { m.Text = r.Replace(m.Text, (match) => { return(string.Format("[img{1}]{0}[/img]", match.Groups[1].Value, string.Format("max-width:{0};max-height:{1};", Main.Properties.Settings.Default.maxImageWidth, Main.Properties.Settings.Default.maxImageHeight))); }); } } if (Polling != null && Polling.Started == PollStatusEnum.Started) { if (_dispatcher.CheckAccess()) { Polling.OnMessage(m); } else { _dispatcher.Invoke(() => { Polling.OnMessage(m); }); } } if (FortuneList != null && FortuneList.Status == FortuneStatusEnum.Started) { if (_dispatcher.CheckAccess()) { FortuneList.OnMessage(m); } else { _dispatcher.Invoke(() => { FortuneList.OnMessage(m); }); } } foreach (var bot in _bots) { bot.OnMessage(m); } }