1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-03 12:47:56 +02:00

Remove trailing whitespace.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2008-12-06 02:28:20 -05:00
parent 3a6b63dff1
commit 2c955af135
476 changed files with 5595 additions and 5547 deletions

View File

@@ -2,14 +2,14 @@
class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Cache', 'DefinitionImpl', null);
}
function testBasicUse() {
$this->assertResult( // need support for label for later
'
@@ -28,7 +28,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</form>'
);
}
function testSelectOption() {
$this->assertResult('
<form action="http://somesite.com/prog/component-select" method="post">
@@ -47,7 +47,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</form>
');
}
function testSelectOptgroup() {
$this->assertResult('
<form action="http://somesite.com/prog/someprog" method="post">
@@ -72,7 +72,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</form>
');
}
function testTextarea() {
$this->assertResult('
<form action="http://somesite.com/prog/text-read" method="post">
@@ -86,9 +86,9 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</form>
');
}
// label tests omitted
function testFieldset() {
$this->assertResult('
<form action="..." method="post">
@@ -109,7 +109,7 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</fieldset>
<fieldset>
<legend>Current Medication</legend>
Are you currently taking any medication?
Are you currently taking any medication?
<input name="medication_now" type="radio" value="Yes" tabindex="35" />Yes
<input name="medication_now" type="radio" value="No" tabindex="35" />No
@@ -120,18 +120,18 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
</form>
');
}
function testInputTransform() {
$this->assertResult('<input type="checkbox" />', '<input type="checkbox" value="" />');
}
function testTextareaTransform() {
$this->assertResult('<textarea></textarea>', '<textarea cols="22" rows="3"></textarea>');
}
function testTextInFieldset() {
$this->assertResult('<fieldset> <legend></legend>foo</fieldset>');
}
}

View File

@@ -2,26 +2,26 @@
class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
{
function testNormal() {
$this->assertResult('<img height="40" width="40" src="" alt="" />');
}
function testLengthTooLarge() {
$this->assertResult(
'<img height="40000" width="40000" src="" alt="" />',
'<img height="1200" width="1200" src="" alt="" />'
);
}
function testLengthPercentage() {
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />',
'<img src="" alt="" />'
);
}
function testLengthCustomMax() {
$this->config->set('HTML', 'MaxImgLength', 20);
$this->assertResult(
@@ -29,7 +29,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
'<img height="20" width="20" src="" alt="" />'
);
}
function testLengthCrashFixDisabled() {
$this->config->set('HTML', 'MaxImgLength', null);
$this->assertResult(
@@ -39,7 +39,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
'<img height="40000" width="40000" src="" alt="" />'
);
}
function testLengthTrusted() {
$this->config->set('HTML', 'Trusted', true);
$this->assertResult(
@@ -49,6 +49,6 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
'<img height="40000" width="40000" src="" alt="" />'
);
}
}

View File

@@ -2,23 +2,23 @@
class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
}
function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false);
$this->assertResult(
'<object></object>', ''
);
}
function testMinimal() {
$this->assertResult('<object></object>');
}
function testStandardUseCase() {
$this->assertResult(
'<object type="video/x-ms-wmv" data="http://domain.com/video.wmv" width="320" height="256">
@@ -30,8 +30,8 @@ class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
</object>'
);
}
// more test-cases?
}

View File

@@ -2,12 +2,12 @@
class HTMLPurifier_HTMLModule_ProprietaryTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Proprietary', true);
}
function testMarquee() {
$this->assertResult(
'<span><marquee
@@ -24,6 +24,6 @@ class HTMLPurifier_HTMLModule_ProprietaryTest extends HTMLPurifier_HTMLModuleHar
><div>Block</div><span>Inline</span>Text</marquee></span>'
);
}
}

View File

@@ -2,24 +2,24 @@
class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Doctype', 'XHTML 1.1');
}
function testBasicUse() {
$this->assertResult(
'<ruby><rb>WWW</rb><rt>World Wide Web</rt></ruby>'
);
}
function testRPUse() {
$this->assertResult(
'<ruby><rb>WWW</rb><rp>(</rp><rt>World Wide Web</rt><rp>)</rp></ruby>'
);
}
function testComplexUse() {
$this->assertResult(
'<ruby>
@@ -38,7 +38,7 @@ class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
</rtc>
</ruby>'
);
/* not implemented
function testBackwardsCompat() {
$this->assertResult(
@@ -47,8 +47,8 @@ class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
);
}
*/
}
}

View File

@@ -2,40 +2,40 @@
class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeEmbedTest');
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeEmbed');
}
function testMinimal() {
$this->assertResult(
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" />',
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" allowscriptaccess="never" allownetworking="internal" type="application/x-shockwave-flash" />'
);
}
function testYouTube() {
$this->assertResult(
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed>',
'<embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="425" height="344" allowscriptaccess="never" allownetworking="internal" />'
);
}
function testMalicious() {
$this->assertResult(
'<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="9999999" height="3499994" allowscriptaccess="always" allownetworking="always" />',
'<embed src="http://example.com/bad.swf" type="application/x-shockwave-flash" width="1200" height="1200" allowscriptaccess="never" allownetworking="internal" />'
);
}
function testFull() {
$this->assertResult(
'<b><embed src="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash" width="24" height="23" allowscriptaccess="never" allownetworking="internal" wmode="window" /></b>'
);
}
}

View File

@@ -2,21 +2,21 @@
class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeObject');
}
function testMinimal() {
$this->assertResult(
'<object></object>',
'<object type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testYouTube() {
// embed is purposely removed
$this->assertResult(
@@ -24,19 +24,19 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
'<object width="425" height="344" data="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /></object>'
);
}
function testMalicious() {
$this->assertResult(
'<object width="9999999" height="9999999"><param name="allowScriptAccess" value="always" /><param name="movie" value="http://example.com/attack.swf" /></object>',
'<object width="1200" height="1200" data="http://example.com/attack.swf" type="application/x-shockwave-flash"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://example.com/attack.swf" /></object>'
);
}
function testFull() {
$this->assertResult(
'<b><object width="425" height="344" type="application/x-shockwave-flash" data="Foobar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /></object></b>'
);
}
}

View File

@@ -2,26 +2,26 @@
class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
$this->config->set('Output', 'CommentScriptContents', false);
}
function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false);
$this->assertResult(
'<script type="text/javascript">foo();</script>', ''
);
}
function testPreserve() {
$this->assertResult(
'<script type="text/javascript">foo();</script>'
);
}
function testCDATAEnclosure() {
$this->assertResult(
'<script type="text/javascript">//<![CDATA[
@@ -29,7 +29,7 @@ alert("<This is compatible with XHTML>");
//]]></script>'
);
}
function testAllAttributes() {
$this->assertResult(
'<script
@@ -39,7 +39,7 @@ alert("<This is compatible with XHTML>");
>PCDATA</script>'
);
}
function testUnsupportedAttributes() {
$this->assertResult(
'<script
@@ -49,6 +49,6 @@ alert("<This is compatible with XHTML>");
'<script type="text/javascript">PCDATA</script>'
);
}
}

View File

@@ -8,14 +8,14 @@ Mock::generatePartial(
class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
{
function test_getFixesForLevel() {
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->fixesForLevel['light'][] = 'light-fix';
$module->fixesForLevel['medium'][] = 'medium-fix';
$module->fixesForLevel['heavy'][] = 'heavy-fix';
$this->assertIdentical(
array(),
$module->getFixesForLevel('none')
@@ -32,22 +32,22 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
array('light-fix' => true, 'medium-fix' => true, 'heavy-fix' => true),
$module->getFixesForLevel('heavy')
);
$this->expectError('Tidy level turbo not recognized');
$module->getFixesForLevel('turbo');
}
function test_setup() {
$i = 0; // counter, helps us isolate expectations
// initialize partial mock
$module = new HTMLPurifier_HTMLModule_Tidy_TestForConstruct();
$module->fixesForLevel['light'] = array('light-fix-1', 'light-fix-2');
$module->fixesForLevel['medium'] = array('medium-fix-1', 'medium-fix-2');
$module->fixesForLevel['heavy'] = array('heavy-fix-1', 'heavy-fix-2');
$j = 0;
$fixes = array(
'light-fix-1' => $lf1 = $j++,
@@ -58,15 +58,15 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'heavy-fix-2' => $hf2 = $j++
);
$module->setReturnValue('makeFixes', $fixes);
$config = HTMLPurifier_Config::create(array(
'HTML.TidyLevel' => 'none'
));
$module->expectAt($i++, 'populate', array(array()));
$module->setup($config);
// basic levels
$config = HTMLPurifier_Config::create(array(
'HTML.TidyLevel' => 'light'
));
@@ -75,7 +75,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'light-fix-2' => $lf2
)));
$module->setup($config);
$config = HTMLPurifier_Config::create(array(
'HTML.TidyLevel' => 'heavy'
));
@@ -88,9 +88,9 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'heavy-fix-2' => $hf2
)));
$module->setup($config);
// fine grained tuning
$config = HTMLPurifier_Config::create(array(
'HTML.TidyLevel' => 'none',
'HTML.TidyAdd' => array('light-fix-1', 'medium-fix-1')
@@ -100,7 +100,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'medium-fix-1' => $mf1
)));
$module->setup($config);
$config = HTMLPurifier_Config::create(array(
'HTML.TidyLevel' => 'medium',
'HTML.TidyRemove' => array('light-fix-1', 'medium-fix-1')
@@ -110,90 +110,90 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'medium-fix-2' => $mf2
)));
$module->setup($config);
}
function test_makeFixesForLevel() {
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->defaultLevel = 'heavy';
$module->makeFixesForLevel(array(
'fix-1' => 0,
'fix-2' => 1,
'fix-3' => 2
));
$this->assertIdentical($module->fixesForLevel['heavy'], array('fix-1', 'fix-2', 'fix-3'));
$this->assertIdentical($module->fixesForLevel['medium'], array());
$this->assertIdentical($module->fixesForLevel['light'], array());
}
function test_makeFixesForLevel_undefinedLevel() {
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->defaultLevel = 'bananas';
$this->expectError('Default level bananas does not exist');
$module->makeFixesForLevel(array(
'fix-1' => 0
));
}
function test_getFixType() {
// syntax needs documenting
$module = new HTMLPurifier_HTMLModule_Tidy();
$this->assertIdentical(
$module->getFixType('a'),
array('tag_transform', array('element' => 'a'))
);
$this->assertIdentical(
$module->getFixType('a@href'),
$reuse = array('attr_transform_pre', array('element' => 'a', 'attr' => 'href'))
);
$this->assertIdentical(
$module->getFixType('a@href#pre'),
$reuse
);
$this->assertIdentical(
$module->getFixType('a@href#post'),
array('attr_transform_post', array('element' => 'a', 'attr' => 'href'))
);
$this->assertIdentical(
$module->getFixType('xml:foo@xml:bar'),
array('attr_transform_pre', array('element' => 'xml:foo', 'attr' => 'xml:bar'))
);
$this->assertIdentical(
$module->getFixType('blockquote#child'),
array('child', array('element' => 'blockquote'))
);
$this->assertIdentical(
$module->getFixType('@lang'),
array('attr_transform_pre', array('attr' => 'lang'))
);
$this->assertIdentical(
$module->getFixType('@lang#post'),
array('attr_transform_post', array('attr' => 'lang'))
);
}
function test_populate() {
$i = 0;
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->populate(array(
'element' => $element = $i++,
@@ -204,7 +204,7 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
'@attr' => $global_attr = $i++,
'@attr#post' => $global_attr_post = $i++
));
$module2 = new HTMLPurifier_HTMLModule_Tidy();
$e = $module2->addBlankElement('element');
$e->attr_transform_pre['attr'] = $attr;
@@ -214,10 +214,10 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
$module2->info_tag_transform['element'] = $element;
$module2->info_attr_transform_pre['attr'] = $global_attr;
$module2->info_attr_transform_post['attr'] = $global_attr_post;
$this->assertEqual($module, $module2);
}
}