diff --git a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs index 3362a36e..d8ab8b66 100644 --- a/SafeExamBrowser.Browser/Handlers/RequestHandler.cs +++ b/SafeExamBrowser.Browser/Handlers/RequestHandler.cs @@ -7,6 +7,7 @@ */ using System; +using System.Text.RegularExpressions; using CefSharp; using SafeExamBrowser.Browser.Contracts.Filters; using SafeExamBrowser.Browser.Events; @@ -23,6 +24,7 @@ namespace SafeExamBrowser.Browser.Handlers { private IRequestFilter filter; private ILogger logger; + private string quitUrlPattern; private ResourceHandler resourceHandler; private BrowserSettings settings; @@ -81,11 +83,21 @@ namespace SafeExamBrowser.Browser.Handlers private bool IsQuitUrl(IRequest request) { - var isQuitUrl = settings.QuitUrl?.Equals(request.Url, StringComparison.OrdinalIgnoreCase) == true; + var isQuitUrl = false; - if (isQuitUrl) + if (!string.IsNullOrWhiteSpace(settings.QuitUrl)) { - logger.Debug($"Detected quit URL '{request.Url}'."); + if (quitUrlPattern == default(string)) + { + quitUrlPattern = Regex.Escape(settings.QuitUrl.TrimEnd('/')) + @"\/?"; + } + + isQuitUrl = Regex.IsMatch(request.Url, quitUrlPattern, RegexOptions.IgnoreCase); + + if (isQuitUrl) + { + logger.Debug($"Detected quit URL '{request.Url}'."); + } } return isQuitUrl; diff --git a/SafeExamBrowser.SystemComponents/UserInfo.cs b/SafeExamBrowser.SystemComponents/UserInfo.cs index 196283f4..cd7e265f 100644 --- a/SafeExamBrowser.SystemComponents/UserInfo.cs +++ b/SafeExamBrowser.SystemComponents/UserInfo.cs @@ -89,7 +89,7 @@ namespace SafeExamBrowser.SystemComponents { var process = new Process(); - process.StartInfo.Arguments = string.Format("/c \"wmic useraccount where name='{0}' get sid\"", userName); + process.StartInfo.Arguments = $"/c \"wmic useraccount where name='{userName}' get sid\""; process.StartInfo.CreateNoWindow = true; process.StartInfo.FileName = "cmd.exe"; process.StartInfo.RedirectStandardOutput = true;