SEBWIN-379: Fixed request filter expressions containing trailing slashes after host.

This commit is contained in:
Damian Büchel 2020-03-11 11:33:52 +01:00
parent e5659632b9
commit 54b5be830e
2 changed files with 39 additions and 1 deletions

View file

@ -265,6 +265,44 @@ namespace SafeExamBrowser.Browser.UnitTests.Filters.Rules
Test(expression, positive, negative);
}
[TestMethod]
public void TestHostWithTrailingSlash()
{
var expression = "host.org/";
var positive = new[]
{
"scheme://host.org",
"scheme://host.org/",
"scheme://host.org/url",
"scheme://host.org/url/",
"scheme://host.org/url/path",
"scheme://host.org/url/path/",
"scheme://user:password@www.host.org/url/path?param=123#fragment",
"scheme://user:password@www.host.org/url/path/?param=123#fragment"
};
Test(expression, positive, Array.Empty<string>());
}
[TestMethod]
public void TestHostWithoutTrailingSlash()
{
var expression = "host.org";
var positive = new[]
{
"scheme://host.org",
"scheme://host.org/",
"scheme://host.org/url",
"scheme://host.org/url/",
"scheme://host.org/url/path",
"scheme://host.org/url/path/",
"scheme://user:password@www.host.org/url/path?param=123#fragment",
"scheme://user:password@www.host.org/url/path/?param=123#fragment"
};
Test(expression, positive, Array.Empty<string>());
}
[TestMethod]
public void TestPortNumber()
{

View file

@ -118,7 +118,7 @@ namespace SafeExamBrowser.Browser.Filters.Rules
private void ParsePath(string expression)
{
if (!string.IsNullOrWhiteSpace(expression))
if (!string.IsNullOrWhiteSpace(expression) && !expression.Equals("/"))
{
expression = Regex.Escape(expression);
expression = ReplaceWildcard(expression);