1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

[3.1.0] Deprecate addFilter; set up Filter namespace

- Added EXTERNAL dependency config-schema value
- Fix safe bug in Printer_HTMLDefinition
- Fixed broken smoketests

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1669 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2008-04-22 06:40:04 +00:00
parent e616f07739
commit e1876c18ad
26 changed files with 193 additions and 71 deletions

View File

@@ -8,8 +8,8 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
// usual use case:
function test_tokenizeHTML_extractStyleBlocks() {
$this->config->set('Filter', 'ExtractStyleBlocks', true);
$purifier = new HTMLPurifier($this->config);
$purifier->addFilter(new HTMLPurifier_Filter_ExtractStyleBlocks());
$result = $purifier->purify('<style type="text/css">.foo {text-align:center;bogus:remove-me;}</style>Test<style>* {font-size:12pt;}</style>');
$this->assertIdentical($result, 'Test');
$this->assertIdentical($purifier->context->get('StyleBlocks'),
@@ -21,8 +21,9 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function assertExtractStyleBlocks($html, $expect = true, $styles = array()) {
$filter = new HTMLPurifier_Filter_ExtractStyleBlocks(false); // disable cleaning
$filter = new HTMLPurifier_Filter_ExtractStyleBlocks(); // disable cleaning
if ($expect === true) $expect = $html;
$this->config->set('FilterParam', 'ExtractStyleBlocksTidyImpl', false);
$result = $filter->preFilter($html, $this->config, $this->context);
$this->assertIdentical($result, $expect);
$this->assertIdentical($this->context->get('StyleBlocks'), $styles);
@@ -103,14 +104,14 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_noEscapeCodes() {
$this->config->set('Filter', 'ExtractStyleBlocksEscaping', false);
$this->config->set('FilterParam', 'ExtractStyleBlocksEscaping', false);
$this->assertCleanCSS(
".class {\nfont-family:'</style>';\n}"
);
}
function test_cleanCSS_scope() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(
"p {\ntext-indent:1em;\n}",
"#foo p {\ntext-indent:1em;\n}"
@@ -118,7 +119,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithSelectorCommas() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(
"b, i {\ntext-decoration:underline;\n}",
"#foo b, #foo i {\ntext-decoration:underline;\n}"
@@ -126,17 +127,17 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithNaughtySelector() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" + p {\ntext-indent:1em;\n}", '');
}
function test_cleanCSS_scopeWithMultipleNaughtySelectors() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" ++ ++ p {\ntext-indent:1em;\n}", '');
}
function test_cleanCSS_scopeWithCommas() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS(
"p {\ntext-indent:1em;\n}",
"#foo p, .bar p {\ntext-indent:1em;\n}"
@@ -144,7 +145,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeAllWithCommas() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS(
"p, div {\ntext-indent:1em;\n}",
"#foo p, #foo div, .bar p, .bar div {\ntext-indent:1em;\n}"
@@ -152,7 +153,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithConflicts() {
$this->config->set('Filter', 'ExtractStyleBlocksScope', 'p');
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', 'p');
$this->assertCleanCSS(
"div {
text-align:right;