1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 06:07:26 +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,19 +2,19 @@
class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'AutoParagraph', true);
}
function testSingleParagraph() {
$this->assertResult(
'Foobar',
'<p>Foobar</p>'
);
}
function testSingleMultiLineParagraph() {
$this->assertResult(
'Par 1
@@ -23,7 +23,7 @@ Par 1 still',
Par 1 still</p>'
);
}
function testTwoParagraphs() {
$this->assertResult(
'Par1
@@ -34,12 +34,12 @@ Par2',
<p>Par2</p>"
);
}
function testTwoParagraphsWithLotsOfSpace() {
$this->assertResult(
'Par1
Par2',
'<p>Par1</p>
@@ -47,7 +47,7 @@ Par2',
<p>Par2</p>'
);
}
function testTwoParagraphsWithInlineElements() {
$this->assertResult(
'<b>Par1</b>
@@ -58,7 +58,7 @@ Par2',
<p><i>Par2</i></p>'
);
}
function testSingleParagraphThatLooksLikeTwo() {
$this->assertResult(
'<b>Par1
@@ -69,7 +69,7 @@ Par2</b>',
Par2</b></p>'
);
}
function testAddParagraphAdjacentToParagraph() {
$this->assertResult(
'Par1<p>Par2</p>',
@@ -78,14 +78,14 @@ Par2</b></p>'
<p>Par2</p>'
);
}
function testParagraphUnclosedInlineElement() {
$this->assertResult(
'<b>Par1',
'<p><b>Par1</b></p>'
);
}
function testPreservePreTags() {
$this->assertResult(
'<pre>Par1
@@ -93,7 +93,7 @@ Par2</b></p>'
Par1</pre>'
);
}
function testIgnoreTrailingWhitespace() {
$this->assertResult(
'Par1
@@ -104,7 +104,7 @@ Par1</pre>'
'
);
}
function testDoNotParagraphBlockElements() {
$this->assertResult(
'Par1
@@ -119,14 +119,14 @@ Par3',
<p>Par3</p>'
);
}
function testParagraphTextAndInlineNodes() {
$this->assertResult(
'Par<b>1</b>',
'<p>Par<b>1</b></p>'
);
}
function testPreserveLeadingWhitespace() {
$this->assertResult(
'
@@ -137,7 +137,7 @@ Par',
<p>Par</p>'
);
}
function testPreserveSurroundingWhitespace() {
$this->assertResult(
'
@@ -152,7 +152,7 @@ Par
'
);
}
function testParagraphInsideBlockNode() {
$this->assertResult(
'<div>Par1
@@ -163,7 +163,7 @@ Par2</div>',
<p>Par2</p></div>'
);
}
function testParagraphInlineNodeInsideBlockNode() {
$this->assertResult(
'<div><b>Par1</b>
@@ -174,11 +174,11 @@ Par2</div>',
<p>Par2</p></div>'
);
}
function testNoParagraphWhenOnlyOneInsideBlockNode() {
$this->assertResult('<div>Par1</div>');
}
function testParagraphTwoInlineNodesInsideBlockNode() {
$this->assertResult(
'<div><b>Par1</b>
@@ -189,7 +189,7 @@ Par2</div>',
<p><i>Par2</i></p></div>'
);
}
function testPreserveInlineNodesInPreTag() {
$this->assertResult(
'<pre><b>Par1</b>
@@ -197,7 +197,7 @@ Par2</div>',
<i>Par2</i></pre>'
);
}
function testSplitUpInternalsOfPTagInBlockNode() {
$this->assertResult(
'<div><p>Foo
@@ -208,7 +208,7 @@ Bar</p></div>',
<p>Bar</p></div>'
);
}
function testSplitUpInlineNodesInPTagInBlockNode() {
$this->assertResult(
'<div><p><b>Foo</b>
@@ -219,11 +219,11 @@ Bar</p></div>',
<p><i>Bar</i></p></div>'
);
}
function testNoParagraphSingleInlineNodeInBlockNode() {
$this->assertResult( '<div><b>Foo</b></div>' );
}
function testParagraphInBlockquote() {
$this->assertResult(
'<blockquote>Par1
@@ -234,7 +234,7 @@ Par2</blockquote>',
<p>Par2</p></blockquote>'
);
}
function testNoParagraphBetweenListItem() {
$this->assertResult(
'<ul><li>Foo</li>
@@ -242,14 +242,14 @@ Par2</blockquote>',
<li>Bar</li></ul>'
);
}
function testParagraphSingleElementWithSurroundingSpace() {
$this->assertResult(
'<div>
Bar
</div>',
</div>',
'<div>
<p>Bar</p>
@@ -257,42 +257,42 @@ Bar
</div>'
);
}
function testIgnoreExtraSpaceWithLeadingInlineNode() {
$this->assertResult(
'<b>Par1</b>a
Par2',
Par2',
'<p><b>Par1</b>a</p>
<p>Par2</p>'
);
}
function testAbsorbExtraEndingPTag() {
$this->assertResult(
'Par1
Par2</p>',
Par2</p>',
'<p>Par1</p>
<p>Par2</p>'
);
}
function testAbsorbExtraEndingDivTag() {
$this->assertResult(
'Par1
Par2</div>',
Par2</div>',
'<p>Par1</p>
<p>Par2</p>'
);
}
function testDoNotParagraphSingleSurroundingSpaceInBlockNode() {
$this->assertResult(
'<div>
@@ -300,7 +300,7 @@ Par1
</div>'
);
}
function testBlockNodeTextDelimeterInBlockNode() {
$this->assertResult(
'<div>Par1
@@ -311,14 +311,14 @@ Par1
<div>Par2</div></div>'
);
}
function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode() {
$this->assertResult(
'<div>Par1
<div>Par2</div></div>'
);
}
function testBlockNodeTextDelimeterWithoutDoublespace() {
$this->assertResult(
'Par1
@@ -329,7 +329,7 @@ Par1
<div>Par2</div>'
);
}
function testTwoParagraphsOfTextAndInlineNode() {
$this->assertResult(
'Par1
@@ -340,32 +340,32 @@ Par1
<p><b>Par2</b></p>'
);
}
function testLeadingInlineNodeParagraph() {
$this->assertResult(
'<img /> Foo',
'<p><img /> Foo</p>'
);
}
function testTrailingInlineNodeParagraph() {
$this->assertResult(
'<li>Foo <a>bar</a></li>'
);
}
function testTwoInlineNodeParagraph() {
$this->assertResult(
'<li><b>baz</b><a>bar</a></li>'
);
}
function testNoParagraphTrailingBlockNodeInBlockNode() {
$this->assertResult(
'<div><div>asdf</div><b>asdf</b></div>'
);
}
function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode() {
$this->assertResult(
'<div><div>asdf</div>
@@ -376,14 +376,14 @@ Par1
<p><b>asdf</b></p></div>'
);
}
function testParagraphTwoInlineNodesAndWhitespaceNode() {
$this->assertResult(
'<b>One</b> <i>Two</i>',
'<p><b>One</b> <i>Two</i></p>'
);
}
function testNoParagraphWithInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span');
$this->assertResult(
@@ -392,13 +392,13 @@ Par1
Par2'
);
}
function testInlineAndBlockTagInDivNoParagraph() {
$this->assertResult(
'<div><code>bar</code> mmm <pre>asdf</pre></div>'
);
}
function testInlineAndBlockTagInDivNeedingParagraph() {
$this->assertResult(
'<div><code>bar</code> mmm
@@ -409,7 +409,7 @@ Par2'
<pre>asdf</pre></div>'
);
}
function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph() {
$this->assertResult(
'<div>asdf <code>bar</code> mmm
@@ -420,7 +420,7 @@ Par2'
<pre>asdf</pre></div>'
);
}
function testUpcomingTokenHasNewline() {
$this->assertResult(
'<div>Test<b>foo</b>bar<b>bing</b>bang
@@ -431,7 +431,7 @@ boo</div>',
<p>boo</p></div>'
);
}
function testEmptyTokenAtEndOfDiv() {
$this->assertResult(
'<div><p>foo</p>
@@ -440,7 +440,7 @@ boo</div>',
</div>'
);
}
function testEmptyDoubleLineTokenAtEndOfDiv() {
$this->assertResult(
'<div><p>foo</p>
@@ -451,26 +451,26 @@ boo</div>',
</div>'
);
}
function testTextState11Root() {
$this->assertResult('<div></div> ');
}
function testTextState11Element() {
$this->assertResult(
"<div><div></div>
</div>");
}
function testTextStateLikeElementState111NoWhitespace() {
$this->assertResult('<div><p>P</p>Boo</div>', '<div><p>P</p>Boo</div>');
}
function testElementState111NoWhitespace() {
$this->assertResult('<div><p>P</p><b>Boo</b></div>', '<div><p>P</p><b>Boo</b></div>');
}
function testElementState133() {
$this->assertResult(
"<div><b>B</b><pre>Ba</pre>
@@ -481,13 +481,13 @@ Bar</div>",
<p>Bar</p></div>"
);
}
function testElementState22() {
$this->assertResult(
'<ul><li>foo</li></ul>'
);
}
function testElementState311() {
$this->assertResult(
'<p>Foo</p><b>Bar</b>',
@@ -496,12 +496,12 @@ Bar</div>",
<p><b>Bar</b></p>'
);
}
function testErrorNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->assertResult('<b>foobar</b>');
}
}

View File

@@ -2,19 +2,19 @@
class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'DisplayLinkURI', true);
}
function testBasicLink() {
$this->assertResult(
'<a href="http://malware.example.com">Don\'t go here!</a>',
'<a>Don\'t go here!</a> (http://malware.example.com)'
);
}
function testEmptyLink() {
$this->assertResult(
'<a>Don\'t go here!</a>',
@@ -27,6 +27,6 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn
'<a></a> (http://malware.example.com)'
);
}
}
?>

View File

@@ -2,44 +2,44 @@
class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'Linkify', true);
}
function testLinkifyURLInRootNode() {
$this->assertResult(
'http://example.com',
'<a href="http://example.com">http://example.com</a>'
);
}
function testLinkifyURLInInlineNode() {
$this->assertResult(
'<b>http://example.com</b>',
'<b><a href="http://example.com">http://example.com</a></b>'
);
}
function testBasicUsageCase() {
$this->assertResult(
'This URL http://example.com is what you need',
'This URL <a href="http://example.com">http://example.com</a> is what you need'
);
}
function testIgnoreURLInATag() {
$this->assertResult(
'<a>http://example.com/</a>'
);
}
function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('http://example.com/');
}
}

View File

@@ -2,57 +2,57 @@
class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'PurifierLinkify', true);
$this->config->set('AutoFormatParam', 'PurifierLinkifyDocURL', '#%s');
}
function testNoTriggerCharacer() {
$this->assertResult('Foobar');
}
function testTriggerCharacterInIrrelevantContext() {
$this->assertResult('20% off!');
}
function testPreserveNamespace() {
$this->assertResult('%Core namespace (not recognized)');
}
function testLinkifyBasic() {
$this->assertResult(
'%Namespace.Directive',
'<a href="#Namespace.Directive">%Namespace.Directive</a>'
);
}
function testLinkifyWithAdjacentTextNodes() {
$this->assertResult(
'This %Namespace.Directive thing',
'This <a href="#Namespace.Directive">%Namespace.Directive</a> thing'
);
}
function testLinkifyInBlock() {
$this->assertResult(
'<div>This %Namespace.Directive thing</div>',
'<div>This <a href="#Namespace.Directive">%Namespace.Directive</a> thing</div>'
);
}
function testPreserveInATag() {
$this->assertResult(
'<a>%Namespace.Directive</a>'
);
}
function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
$this->assertResult('%Namespace.Directive');
}
}

View File

@@ -2,57 +2,57 @@
class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
{
public function setup() {
parent::setup();
$this->config->set('AutoFormat', 'RemoveEmpty', true);
}
function testPreserve() {
$this->assertResult('<b>asdf</b>');
}
function testRemove() {
$this->assertResult('<b></b>', '');
}
function testRemoveWithSpace() {
$this->assertResult('<b> </b>', '');
}
function testRemoveWithAttr() {
$this->assertResult('<b class="asdf"></b>', '');
}
function testRemoveIdAndName() {
$this->assertResult('<a id="asdf" name="asdf"></a>', '');
}
function testPreserveColgroup() {
$this->assertResult('<colgroup></colgroup>');
}
function testPreserveId() {
$this->config->set('Attr', 'EnableID', true);
$this->assertResult('<a id="asdf"></a>');
}
function testPreserveName() {
$this->config->set('Attr', 'EnableID', true);
$this->assertResult('<a name="asdf"></a>');
}
function testRemoveNested() {
$this->assertResult('<b><i></i></b>', '');
}
function testRemoveNested2() {
$this->assertResult('<b><i><u></u></i></b>', '');
}
function testRemoveNested3() {
$this->assertResult('<b> <i> <u> </u> </i> </b>', '');
}
}

View File

@@ -7,81 +7,81 @@
*/
class HTMLPurifier_Injector_SafeObjectTest extends HTMLPurifier_InjectorHarness
{
function setup() {
parent::setup();
// there is no AutoFormat.SafeObject directive
$this->config->set('AutoFormat', 'Custom', array(new HTMLPurifier_Injector_SafeObject()));
$this->config->set('HTML', 'Trusted', true);
}
function testPreserve() {
$this->assertResult(
'<b>asdf</b>'
);
}
function testRemoveStrayParam() {
$this->assertResult(
'<param />',
''
);
}
function testEditObjectParam() {
$this->assertResult(
'<object></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testIgnoreStrayParam() {
$this->assertResult(
'<object><param /></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testIgnoreDuplicates() {
$this->assertResult(
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testIgnoreBogusData() {
$this->assertResult(
'<object><param name="allowScriptAccess" value="always" /><param name="allowNetworking" value="always" /></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testIgnoreInvalidData() {
$this->assertResult(
'<object><param name="foo" value="bar" /></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
);
}
function testKeepValidData() {
$this->assertResult(
'<object><param name="movie" value="bar" /></object>',
'<object data="bar"><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><param name="movie" value="bar" /></object>'
);
}
function testNested() {
$this->assertResult(
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><object></object></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object></object>'
);
}
function testNotActuallyNested() {
$this->assertResult(
'<object><p><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></p></object>',
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><p></p></object>'
);
}
}