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

PSR-2 reformatting PHPDoc corrections

With minor corrections.

Signed-off-by: Marcus Bointon <marcus@synchromedia.co.uk>
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
This commit is contained in:
Marcus Bointon
2013-07-16 13:56:14 +02:00
committed by Edward Z. Yang
parent 19eee14899
commit fac747bdbd
433 changed files with 13302 additions and 6690 deletions

View File

@@ -3,13 +3,15 @@
class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Trusted', true);
$this->config->set('Attr.EnableID', true);
}
function testBasicUse() {
public function testBasicUse()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult( // need support for label for later
'
@@ -29,7 +31,8 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
);
}
function testSelectOption() {
public function testSelectOption()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/component-select" method="post">
@@ -49,7 +52,8 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
');
}
function testSelectOptgroup() {
public function testSelectOptgroup()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/someprog" method="post">
@@ -75,7 +79,8 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
');
}
function testTextarea() {
public function testTextarea()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="http://somesite.com/prog/text-read" method="post">
@@ -92,7 +97,8 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
// label tests omitted
function testFieldset() {
public function testFieldset()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('
<form action="..." method="post">
@@ -125,27 +131,32 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
');
}
function testInputTransform() {
public function testInputTransform()
{
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->assertResult('<input type="checkbox" />', '<input type="checkbox" value="" />');
}
function testTextareaTransform() {
public function testTextareaTransform()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<textarea></textarea>', '<textarea cols="22" rows="3"></textarea>');
}
function testTextInFieldset() {
public function testTextInFieldset()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<fieldset> <legend></legend>foo</fieldset>');
}
function testStrict() {
public function testStrict()
{
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<form action=""></form>', '');
}
function testLegacy() {
public function testLegacy()
{
$this->assertResult('<form action=""></form>');
$this->assertResult('<form action=""><input align="left" /></form>');
}

View File

@@ -4,25 +4,29 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
{
function testNormal() {
public function testNormal()
{
$this->assertResult('<img height="40" width="40" src="" alt="" />');
}
function testLengthTooLarge() {
public function testLengthTooLarge()
{
$this->assertResult(
'<img height="40000" width="40000" src="" alt="" />',
'<img height="1200" width="1200" src="" alt="" />'
);
}
function testLengthPercentage() {
public function testLengthPercentage()
{
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />',
'<img src="" alt="" />'
);
}
function testLengthCustomMax() {
public function testLengthCustomMax()
{
$this->config->set('HTML.MaxImgLength', 20);
$this->assertResult(
'<img height="30" width="30" src="" alt="" />',
@@ -30,7 +34,8 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
);
}
function testLengthCrashFixDisabled() {
public function testLengthCrashFixDisabled()
{
$this->config->set('HTML.MaxImgLength', null);
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />'
@@ -40,7 +45,8 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
);
}
function testLengthTrusted() {
public function testLengthTrusted()
{
$this->config->set('HTML.Trusted', true);
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />'

View File

@@ -3,25 +3,29 @@
class HTMLPurifier_HTMLModule_NameTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
}
function testBasicUse() {
public function testBasicUse()
{
$this->config->set('Attr.EnableID', true);
$this->assertResult(
'<a name="foo">bar</a>'
);
}
function testCDATA() {
public function testCDATA()
{
$this->config->set('HTML.Attr.Name.UseCDATA', true);
$this->assertResult(
'<a name="2">Baz</a><a name="2">Bar</a>'
);
}
function testCDATAWithHeavyTidy() {
public function testCDATAWithHeavyTidy()
{
$this->config->set('HTML.Attr.Name.UseCDATA', true);
$this->config->set('HTML.TidyLevel', 'heavy');
$this->assertResult('<a name="2">Baz</a>');

View File

@@ -3,20 +3,23 @@
class HTMLPurifier_HTMLModule_NofollowTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Nofollow', true);
$this->config->set('Attr.AllowedRel', array("nofollow", "blah"));
}
function testNofollow() {
public function testNofollow()
{
$this->assertResult(
'<a href="http://google.com">x</a><a href="http://google.com" rel="blah">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
);
}
function testNofollowDupe() {
public function testNofollowDupe()
{
$this->assertResult(
'<a href="http://google.com" rel="nofollow">x</a><a href="http://google.com" rel="blah nofollow">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'
);

View File

@@ -3,23 +3,27 @@
class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Trusted', true);
}
function testDefaultRemoval() {
public function testDefaultRemoval()
{
$this->config->set('HTML.Trusted', false);
$this->assertResult(
'<object></object>', ''
);
}
function testMinimal() {
public function testMinimal()
{
$this->assertResult('<object></object>');
}
function testStandardUseCase() {
public function testStandardUseCase()
{
$this->assertResult(
'<object type="video/x-ms-wmv" data="http://domain.com/video.wmv" width="320" height="256">
<param name="src" value="http://domain.com/video.wmv" />

View File

@@ -3,12 +3,14 @@
class HTMLPurifier_HTMLModule_ProprietaryTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Proprietary', true);
}
function testMarquee() {
public function testMarquee()
{
$this->assertResult(
'<span><marquee
width="20%"

View File

@@ -3,24 +3,28 @@
class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Doctype', 'XHTML 1.1');
}
function testBasicUse() {
public function testBasicUse()
{
$this->assertResult(
'<ruby><rb>WWW</rb><rt>World Wide Web</rt></ruby>'
);
}
function testRPUse() {
public function testRPUse()
{
$this->assertResult(
'<ruby><rb>WWW</rb><rp>(</rp><rt>World Wide Web</rt><rp>)</rp></ruby>'
);
}
function testComplexUse() {
public function testComplexUse()
{
$this->assertResult(
'<ruby>
<rbc>
@@ -40,7 +44,8 @@ class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
);
/* not implemented
function testBackwardsCompat() {
function testBackwardsCompat()
{
$this->assertResult(
'<ruby>A<rp>(</rp><rt>aaa</rt><rp>)</rp></ruby>',
'<ruby><rb>A</rb><rp>(</rp><rt>aaa</rt><rp>)</rp></ruby>'

View File

@@ -3,34 +3,39 @@
class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeEmbed');
}
function testMinimal() {
public 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() {
public 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() {
public 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() {
public 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

@@ -3,20 +3,23 @@
class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$this->config->set('HTML.SafeObject', true);
}
function testMinimal() {
public 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() {
public function testYouTube()
{
// embed is purposely removed
$this->assertResult(
'<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&hl=en"></param><embed src="http://www.youtube.com/v/RVtEQxH7PWA&hl=en" type="application/x-shockwave-flash" width="425" height="344"></embed></object>',
@@ -24,20 +27,23 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
);
}
function testMalicious() {
public 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() {
public 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="flashvars" value="foobarbaz=bally" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /></object></b>'
);
}
function testFullScreen() {
public function testFullScreen()
{
$this->config->set('HTML.FlashAllowFullScreen', true);
$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="flashvars" value="foobarbaz=bally" /><param name="movie" value="http://www.youtube.com/v/RVtEQxH7PWA&amp;hl=en" /><param name="wmode" value="window" /><param name="allowFullScreen" value="true" /></object></b>'

View File

@@ -3,25 +3,29 @@
class HTMLPurifier_HTMLModule_SafeScriptingTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.SafeScripting', array('http://localhost/foo.js'));
}
function testMinimal() {
public function testMinimal()
{
$this->assertResult(
'<script></script>',
''
);
}
function testGood() {
public function testGood()
{
$this->assertResult(
'<script type="text/javascript" src="http://localhost/foo.js" />'
);
}
function testBad() {
public function testBad()
{
$this->assertResult(
'<script type="text/javascript" src="http://localhost/foobar.js" />',
''

View File

@@ -3,26 +3,30 @@
class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.Trusted', true);
$this->config->set('Output.CommentScriptContents', false);
}
function testDefaultRemoval() {
public function testDefaultRemoval()
{
$this->config->set('HTML.Trusted', false);
$this->assertResult(
'<script type="text/javascript">foo();</script>', ''
);
}
function testPreserve() {
public function testPreserve()
{
$this->assertResult(
'<script type="text/javascript">foo();</script>'
);
}
function testCDATAEnclosure() {
public function testCDATAEnclosure()
{
$this->assertResult(
'<script type="text/javascript">//<![CDATA[
alert("<This is compatible with XHTML>");
@@ -30,7 +34,8 @@ alert("<This is compatible with XHTML>");
);
}
function testAllAttributes() {
public function testAllAttributes()
{
$this->assertResult(
'<script
defer="defer"
@@ -40,7 +45,8 @@ alert("<This is compatible with XHTML>");
);
}
function testUnsupportedAttributes() {
public function testUnsupportedAttributes()
{
$this->assertResult(
'<script
type="text/javascript"

View File

@@ -3,12 +3,14 @@
class HTMLPurifier_HTMLModule_TargetBlankTest extends HTMLPurifier_HTMLModuleHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->config->set('HTML.TargetBlank', true);
}
function testTargetBlank() {
public function testTargetBlank()
{
$this->assertResult(
'<a href="http://google.com">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>',
'<a href="http://google.com" target="_blank">a</a><a href="/local">b</a><a href="mailto:foo@example.com">c</a>'

View File

@@ -9,8 +9,8 @@ Mock::generatePartial(
class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
{
function test_getFixesForLevel() {
public function test_getFixesForLevel()
{
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->fixesForLevel['light'][] = 'light-fix';
$module->fixesForLevel['medium'][] = 'medium-fix';
@@ -38,8 +38,8 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
}
function test_setup() {
public function test_setup()
{
$i = 0; // counter, helps us isolate expectations
// initialize partial mock
@@ -113,8 +113,8 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
}
function test_makeFixesForLevel() {
public function test_makeFixesForLevel()
{
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->defaultLevel = 'heavy';
@@ -129,8 +129,8 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
$this->assertIdentical($module->fixesForLevel['light'], array());
}
function test_makeFixesForLevel_undefinedLevel() {
public function test_makeFixesForLevel_undefinedLevel()
{
$module = new HTMLPurifier_HTMLModule_Tidy();
$module->defaultLevel = 'bananas';
@@ -142,8 +142,8 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
}
function test_getFixType() {
public function test_getFixType()
{
// syntax needs documenting
$module = new HTMLPurifier_HTMLModule_Tidy();
@@ -190,8 +190,8 @@ class HTMLPurifier_HTMLModule_TidyTest extends HTMLPurifier_Harness
}
function test_populate() {
public function test_populate()
{
$i = 0;
$module = new HTMLPurifier_HTMLModule_Tidy();