5656 * that were originally part of src/test/java/org/owasp/esapi/reference/ValidatorTest.java.
5757 *
5858 * This class tests the cases where the new ESAPI.property
59- * Validator.HtmlValidationAction
59+ * <b> Validator.HtmlValidationAction</b>
6060 * is set to "clean", which causes certain calls to
61- * ESAPI.validator().getValidSafeHTML() or ESAPI.validator().isValidSafeHTML()
61+ * {@code ESAPI.validator().getValidSafeHTML()}
6262 * to simply log a warning and return the cleansed (sanitized) output rather
6363 * than throwing a ValidationException when certain unsafe input is
6464 * encountered.
@@ -275,53 +275,6 @@ public void testAntiSamy_CVE_2023_43643() {
275275 }
276276 ////////////////////////////////////////
277277
278- /**
279- * @deprecated because Validator.isValidSafeHTML is deprecated.
280- * @see org.owasp.esapi.Validator#isValidSafeHTML(String,String,int,boolean)
281- * @see org.owasp.esapi.Validator#isValidSafeHTML(String,String,int,boolean,org.owasp.esapi.ValidationErrorList)
282- */
283- @ Deprecated
284- @ Test
285- public void testIsValidSafeHTML () {
286- System .out .println ("testIsValidSafeHTML" );
287- Validator instance = ESAPI .validator ();
288-
289- assertTrue (instance .isValidSafeHTML ("test" , "<b>Jeff</b>" , 100 , false ));
290- assertTrue (instance .isValidSafeHTML ("test" , "<a href=\" http://www.aspectsecurity.com\" >Aspect Security</a>" , 100 , false ));
291- assertTrue (instance .isValidSafeHTML ("test" , "Test. <script>alert(document.cookie)</script>" , 100 , false ));
292- assertTrue (instance .isValidSafeHTML ("test" , "Test. <div style={xss:expression(xss)}>" , 100 , false ));
293- assertTrue (instance .isValidSafeHTML ("test" , "Test. <s%00cript>alert(document.cookie)</script>" , 100 , false ));
294- assertTrue (instance .isValidSafeHTML ("test" , "Test. <s\t cript>alert(document.cookie)</script>" , 100 , false ));
295- assertTrue (instance .isValidSafeHTML ("test" , "Test. <s\r \n \0 cript>alert(document.cookie)</script>" , 100 , false ));
296-
297- ValidationErrorList errors = new ValidationErrorList ();
298- assertTrue (instance .isValidSafeHTML ("test1" , "<b>Jeff</b>" , 100 , false , errors ));
299- assertTrue (instance .isValidSafeHTML ("test2" , "<a href=\" http://www.aspectsecurity.com\" >Aspect Security</a>" , 100 , false , errors ));
300- assertTrue (instance .isValidSafeHTML ("test3" , "Test. <script>alert(document.cookie)</script>" , 100 , false , errors ));
301- assertTrue (instance .isValidSafeHTML ("test4" , "Test. <div style={xss:expression(xss)}>" , 100 , false , errors ));
302- assertTrue (instance .isValidSafeHTML ("test5" , "Test. <s%00cript>alert(document.cookie)</script>" , 100 , false , errors ));
303- assertTrue (instance .isValidSafeHTML ("test6" , "Test. <s\t cript>alert(document.cookie)</script>" , 100 , false , errors ));
304- assertTrue (instance .isValidSafeHTML ("test7" , "Test. <s\r \n \0 cript>alert(document.cookie)</script>" , 100 , false , errors ));
305- assertTrue (errors .size () == 0 );
306-
307- // Extracted from testIEConditionalComment().
308- String input = "<!--[if gte IE 4]>\r \n <SCRIPT>alert('XSS');</SCRIPT>\r \n <![endif]-->" ;
309- boolean isSafe = instance .isValidSafeHTML ("test12" , input , 100 , false , errors );
310- assertTrue (instance .isValidSafeHTML ("test12" , input , 100 , false , errors )); // Safe bc "" gets returned!!!
311-
312- // Extracted from testNekoDOSWithAnHTMLComment()
313- errors = new ValidationErrorList ();
314- input = "<!--><?a/" ;
315- assertTrue (instance .isValidSafeHTML ("test11" , input , 100 , false , errors )); // Safe bc "" gets returned!!!
316- assertTrue (errors .size () == 0 );
317-
318- // Extracted from testESAPI_CVE_2022_24891()
319- String expectedSafeText = "This is safe from XSS. Trust us!" ;
320- String badVoodoo = "<a href=\" javascript:alert(1)>" + expectedSafeText + "</a>" ;
321- boolean result = instance .isValidSafeHTML ("CVE-2021-35043" , badVoodoo , 200 , false );
322- assertTrue ( result );
323- }
324-
325278 // This test has been significantly changed because as on AntiSamy 1.7.4
326279 // (first used with ESAPI 2.5.3.0) has changed the results of
327280 // Validator.getValidSafeHTMLfor this output. Prior to AntiSamy 1.7.4, the
@@ -335,7 +288,7 @@ public void testIsValidSafeHTML() {
335288 //
336289 // Also, this test, which originally used Validator.isValidSafeHTML(), has been
337290 // changed to use Validator.getValidSafeHTML() instead because Validator.isValidSafeHTML()
338- // has been deprecated . See GitHub Security Advisory
291+ // has been removed as of ESAPI 2.6.0.0 . See GitHub Security Advisory
339292 // https://github.com/ESAPI/esapi-java-legacy/security/advisories/GHSA-r68h-jhhj-9jvm
340293 // and the referenced ESAPI Security Bulletin mentioned therein.
341294 @ Test
@@ -368,7 +321,7 @@ public void testAntiSamyRegressionCDATAWithJavascriptURL() throws Exception {
368321 //
369322 // Also, this test, which originally used Validator.isValidSafeHTML(), has been
370323 // changed to use Validator.getValidSafeHTML() instead because Validator.isValidSafeHTML()
371- // has been deprecated . See GitHub Security Advisory
324+ // has been removed as of ESAPI 2.6.0.0 . See GitHub Security Advisory
372325 // https://github.com/ESAPI/esapi-java-legacy/security/advisories/GHSA-r68h-jhhj-9jvm
373326 // and the referenced ESAPI Security Bulletin mentioned therein.
374327 @ Test
@@ -403,7 +356,7 @@ public void testScriptTagAfterStyleClosing() throws Exception {
403356 //
404357 // Also, this test, which originally used Validator.isValidSafeHTML(), has been
405358 // changed to use Validator.getValidSafeHTML() instead because Validator.isValidSafeHTML()
406- // has been deprecated . See GitHub Security Advisory
359+ // has been removed as of ESAPI 2.6.0.0 . See GitHub Security Advisory
407360 // https://github.com/ESAPI/esapi-java-legacy/security/advisories/GHSA-r68h-jhhj-9jvm
408361 // and the referenced ESAPI Security Bulletin mentioned therein.
409362 @ Test
0 commit comments