SEBWIN-369: Ensured quit link ignores trailing slash.

This commit is contained in:
Damian Büchel 2020-03-02 10:46:42 +01:00
parent 09b7da5eae
commit 7d8720d6a2
2 changed files with 16 additions and 4 deletions

View file

@ -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;

View file

@ -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;