1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-04 13:18:00 +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

@@ -4,34 +4,40 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
HTMLPurifier_StrategyHarness
{
function setUp() {
public function setUp()
{
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
}
function testEmptyInput() {
public function testEmptyInput()
{
$this->assertResult('');
}
function testRemoveIDByDefault() {
public function testRemoveIDByDefault()
{
$this->assertResult(
'<div id="valid">Kill the ID.</div>',
'<div>Kill the ID.</div>'
);
}
function testRemoveInvalidDir() {
public function testRemoveInvalidDir()
{
$this->assertResult(
'<span dir="up-to-down">Bad dir.</span>',
'<span>Bad dir.</span>'
);
}
function testPreserveValidClass() {
public function testPreserveValidClass()
{
$this->assertResult('<div class="valid">Valid</div>');
}
function testSelectivelyRemoveInvalidClasses() {
public function testSelectivelyRemoveInvalidClasses()
{
$this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult(
'<div class="valid 0invalid">Keep valid.</div>',
@@ -39,20 +45,23 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testPreserveTitle() {
public function testPreserveTitle()
{
$this->assertResult(
'<acronym title="PHP: Hypertext Preprocessor">PHP</acronym>'
);
}
function testAddXMLLang() {
public function testAddXMLLang()
{
$this->assertResult(
'<span lang="fr">La soupe.</span>',
'<span lang="fr" xml:lang="fr">La soupe.</span>'
);
}
function testOnlyXMLLangInXHTML11() {
public function testOnlyXMLLangInXHTML11()
{
$this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult(
'<b lang="en">asdf</b>',
@@ -60,32 +69,37 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testBasicURI() {
public function testBasicURI()
{
$this->assertResult('<a href="http://www.google.com/">Google</a>');
}
function testInvalidURI() {
public function testInvalidURI()
{
$this->assertResult(
'<a href="javascript:badstuff();">Google</a>',
'<a>Google</a>'
);
}
function testBdoAddMissingDir() {
public function testBdoAddMissingDir()
{
$this->assertResult(
'<bdo>Go left.</bdo>',
'<bdo dir="ltr">Go left.</bdo>'
);
}
function testBdoReplaceInvalidDirWithDefault() {
public function testBdoReplaceInvalidDirWithDefault()
{
$this->assertResult(
'<bdo dir="blahblah">Invalid value!</bdo>',
'<bdo dir="ltr">Invalid value!</bdo>'
);
}
function testBdoAlternateDefaultDir() {
public function testBdoAlternateDefaultDir()
{
$this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult(
'<bdo>Go right.</bdo>',
@@ -93,14 +107,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testRemoveDirWhenNotRequired() {
public function testRemoveDirWhenNotRequired()
{
$this->assertResult(
'<span dir="blahblah">Invalid value!</span>',
'<span>Invalid value!</span>'
);
}
function testTableAttributes() {
public function testTableAttributes()
{
$this->assertResult(
'<table frame="above" rules="rows" summary="A test table" border="2" cellpadding="5%" cellspacing="3" width="100%">
<col align="right" width="4*" />
@@ -120,14 +136,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testColSpanIsNonZero() {
public function testColSpanIsNonZero()
{
$this->assertResult(
'<col span="0" />',
'<col />'
);
}
function testImgAddDefaults() {
public function testImgAddDefaults()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img />',
@@ -135,14 +153,16 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testImgGenerateAlt() {
public function testImgGenerateAlt()
{
$this->assertResult(
'<img src="foobar.jpg" />',
'<img src="foobar.jpg" alt="foobar.jpg" />'
);
}
function testImgAddDefaultSrc() {
public function testImgAddDefaultSrc()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img alt="pretty picture" />',
@@ -150,7 +170,8 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testImgRemoveNonRetrievableProtocol() {
public function testImgRemoveNonRetrievableProtocol()
{
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img src="mailto:foo@example.com" />',
@@ -158,18 +179,21 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testPreserveRel() {
public function testPreserveRel()
{
$this->config->set('Attr.AllowedRel', 'nofollow');
$this->assertResult('<a href="foo" rel="nofollow" />');
}
function testPreserveTarget() {
public function testPreserveTarget()
{
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$this->assertResult('<a href="foo" target="_top" />');
}
function testRemoveTargetWhenNotSupported() {
public function testRemoveTargetWhenNotSupported()
{
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->assertResult(
@@ -178,20 +202,23 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testKeepAbsoluteCSSWidthAndHeightOnImg() {
public function testKeepAbsoluteCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10px;height:10px;border:1px solid #000;" />'
);
}
function testRemoveLargeCSSWidthAndHeightOnImg() {
public function testRemoveLargeCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
);
}
function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() {
public function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf()
{
$this->config->set('CSS.MaxImgLength', '1px');
$this->assertResult(
'<img src="" alt="" style="width:1mm;height:1mm;border:1px solid #000;" />',
@@ -199,28 +226,32 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
);
}
function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() {
public function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo()
{
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />'
);
}
function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() {
public function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo()
{
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />'
);
}
function testRemoveRelativeCSSWidthAndHeightOnImg() {
public function testRemoveRelativeCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:10em;height:10em;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
);
}
function testRemovePercentCSSWidthAndHeightOnImg() {
public function testRemovePercentCSSWidthAndHeightOnImg()
{
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'