From f7eccc00388f12eca6bdc1be3d532b0df0426fe1 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Tue, 15 May 2007 01:17:10 +0000 Subject: [PATCH] [1.7.0] Add %HTML.Trusted directive to allow untrusted elements in. Add special-case code for " + ); + + $this->config = HTMLPurifier_Config::createDefault(); + $this->config->set('Core', 'CommentScriptContents', false); + + $this->assertGeneration( + array( + new HTMLPurifier_Token_Start('script'), + new HTMLPurifier_Token_Text('alert(3 < 5);'), + new HTMLPurifier_Token_End('script') + ), + "" + ); + } + function test_generateFromTokens_XHTMLoff() { $this->config = HTMLPurifier_Config::createDefault(); $this->config->set('Core', 'XHTML', false); diff --git a/tests/HTMLPurifier/HTMLModule/ScriptingTest.php b/tests/HTMLPurifier/HTMLModule/ScriptingTest.php new file mode 100644 index 00000000..69b83e0a --- /dev/null +++ b/tests/HTMLPurifier/HTMLModule/ScriptingTest.php @@ -0,0 +1,52 @@ +assertResult( + '', 'foo();' + ); + + // enabled + $this->assertResult( + '', true, + array('HTML.Trusted' => true) + ); + + // max + $this->assertResult( + '', true, + array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false) + ); + + // unsupported + $this->assertResult( + '', + '', + array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false) + ); + + // invalid children + $this->assertResult( + '', + '', + array('HTML.Trusted' => true, 'Core.CommentScriptContents' => false) + ); + + } + +} + +?> \ No newline at end of file diff --git a/tests/test_files.php b/tests/test_files.php index 602dc47b..81df7851 100644 --- a/tests/test_files.php +++ b/tests/test_files.php @@ -68,6 +68,7 @@ $test_files[] = 'HTMLModule/EditTest.php'; $test_files[] = 'HTMLModule/HypertextTest.php'; $test_files[] = 'HTMLModule/ImageTest.php'; $test_files[] = 'HTMLModule/LegacyTest.php'; +$test_files[] = 'HTMLModule/ScriptingTest.php'; $test_files[] = 'IDAccumulatorTest.php'; $test_files[] = 'LanguageFactoryTest.php'; $test_files[] = 'LanguageTest.php';