Adding tests for verifying that malicious code input will be cleaned for XSS.

This commit is contained in:
elitsa
2018-12-27 10:02:49 +01:00
parent bb60d5e035
commit 0aa1dc1dc7

View File

@@ -61,6 +61,17 @@ namespace Umbraco.Tests.Strings
Assert.AreEqual(stripped, result);
}
[TestCase("'+alert(1234)+'", "alert1234")]
[TestCase("'+alert(56+78)+'", "alert5678")]
[TestCase("{{file}}", "file")]
[TestCase("'+alert('hello')+'", "alerthello")]
[TestCase("Test", "Test")]
public void Clean_From_XSS(string input, string result)
{
var cleaned = input.CleanForXss();
Assert.AreEqual(cleaned, result);
}
[TestCase("This is a string to encrypt")]
[TestCase("This is a string to encrypt\nThis is a second line")]
[TestCase(" White space is preserved ")]