1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-05 05:37:49 +02:00

[3.0.0] Fully implement CSS extraction and cleaning. See NEWS for more information, it is now a Filter.

- Some Lexer things were moved around

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1469 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-12-12 21:46:30 +00:00
parent 831f552ec5
commit 5b3431d889
9 changed files with 231 additions and 92 deletions

View File

@@ -31,48 +31,6 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
}
// HTMLPurifier_Lexer->extractStyleBlocks() --------------------------------
function assertExtractStyleBlocks($html, $expect = true, $styles = array()) {
$lexer = HTMLPurifier_Lexer::create($this->config);
if ($expect === true) $expect = $html;
$result = $lexer->extractStyleBlocks($html, $this->config, $this->context);
$this->assertIdentical($result, $expect);
$this->assertIdentical($this->context->get('StyleBlocks'), $styles);
}
function test_extractStyleBlocks_preserve() {
$this->assertExtractStyleBlocks('Foobar');
}
function test_extractStyleBlocks_allStyle() {
$this->assertExtractStyleBlocks('<style>foo</style>', '', array('foo'));
}
function test_extractStyleBlocks_multipleBlocks() {
$this->assertExtractStyleBlocks(
"<style>1</style><style>2</style>NOP<style>4</style>",
"NOP",
array('1', '2', '4')
);
}
function test_extractStyleBlocks_blockWithAttributes() {
$this->assertExtractStyleBlocks(
'<style type="text/css">css</style>',
'',
array('css')
);
}
function test_extractStyleBlocks_styleWithPadding() {
$this->assertExtractStyleBlocks(
"Alas<styled>Awesome</styled>\n<style>foo</style> Trendy!",
"Alas<styled>Awesome</styled>\n Trendy!",
array('foo')
);
}
// HTMLPurifier_Lexer->parseData() -----------------------------------------
function assertParseData($input, $expect = true) {
@@ -553,17 +511,6 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
);
}
function test_tokenizeHTML_extractStyleBlocks() {
$this->config->set('HTML', 'ExtractStyleBlocks', true);
$this->assertTokenization(
'<style type="text/css">.foo {text-align:center;}</style>Test',
array(
new HTMLPurifier_Token_Text('Test')
)
);
$this->assertIdentical($this->context->get('StyleBlocks'), array('.foo {text-align:center;}'));
}
/*
function test_tokenizeHTML_() {