mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 06:07:26 +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:
committed by
Edward Z. Yang
parent
19eee14899
commit
fac747bdbd
@@ -3,19 +3,22 @@
|
||||
class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('AutoFormat.AutoParagraph', true);
|
||||
}
|
||||
|
||||
function testSingleParagraph() {
|
||||
public function testSingleParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Foobar',
|
||||
'<p>Foobar</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testSingleMultiLineParagraph() {
|
||||
public function testSingleMultiLineParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par 1
|
||||
Par 1 still',
|
||||
@@ -24,7 +27,8 @@ Par 1 still</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphs() {
|
||||
public function testTwoParagraphs()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -35,7 +39,8 @@ Par2',
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphsWithLotsOfSpace() {
|
||||
public function testTwoParagraphsWithLotsOfSpace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -48,7 +53,8 @@ Par2',
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphsWithInlineElements() {
|
||||
public function testTwoParagraphsWithInlineElements()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>Par1</b>
|
||||
|
||||
@@ -59,7 +65,8 @@ Par2',
|
||||
);
|
||||
}
|
||||
|
||||
function testSingleParagraphThatLooksLikeTwo() {
|
||||
public function testSingleParagraphThatLooksLikeTwo()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>Par1
|
||||
|
||||
@@ -70,7 +77,8 @@ Par2</b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testAddParagraphAdjacentToParagraph() {
|
||||
public function testAddParagraphAdjacentToParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1<p>Par2</p>',
|
||||
'<p>Par1</p>
|
||||
@@ -79,14 +87,16 @@ Par2</b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphUnclosedInlineElement() {
|
||||
public function testParagraphUnclosedInlineElement()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>Par1',
|
||||
'<p><b>Par1</b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testPreservePreTags() {
|
||||
public function testPreservePreTags()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<pre>Par1
|
||||
|
||||
@@ -94,7 +104,8 @@ Par1</pre>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIgnoreTrailingWhitespace() {
|
||||
public function testIgnoreTrailingWhitespace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -105,7 +116,8 @@ Par1</pre>'
|
||||
);
|
||||
}
|
||||
|
||||
function testDoNotParagraphBlockElements() {
|
||||
public function testDoNotParagraphBlockElements()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -120,14 +132,16 @@ Par3',
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphTextAndInlineNodes() {
|
||||
public function testParagraphTextAndInlineNodes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par<b>1</b>',
|
||||
'<p>Par<b>1</b></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testPreserveLeadingWhitespace() {
|
||||
public function testPreserveLeadingWhitespace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'
|
||||
|
||||
@@ -138,7 +152,8 @@ Par',
|
||||
);
|
||||
}
|
||||
|
||||
function testPreserveSurroundingWhitespace() {
|
||||
public function testPreserveSurroundingWhitespace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'
|
||||
|
||||
@@ -153,7 +168,8 @@ Par
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphInsideBlockNode() {
|
||||
public function testParagraphInsideBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>Par1
|
||||
|
||||
@@ -164,7 +180,8 @@ Par2</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphInlineNodeInsideBlockNode() {
|
||||
public function testParagraphInlineNodeInsideBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><b>Par1</b>
|
||||
|
||||
@@ -175,11 +192,13 @@ Par2</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testNoParagraphWhenOnlyOneInsideBlockNode() {
|
||||
public function testNoParagraphWhenOnlyOneInsideBlockNode()
|
||||
{
|
||||
$this->assertResult('<div>Par1</div>');
|
||||
}
|
||||
|
||||
function testParagraphTwoInlineNodesInsideBlockNode() {
|
||||
public function testParagraphTwoInlineNodesInsideBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><b>Par1</b>
|
||||
|
||||
@@ -190,7 +209,8 @@ Par2</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testPreserveInlineNodesInPreTag() {
|
||||
public function testPreserveInlineNodesInPreTag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<pre><b>Par1</b>
|
||||
|
||||
@@ -198,7 +218,8 @@ Par2</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testSplitUpInternalsOfPTagInBlockNode() {
|
||||
public function testSplitUpInternalsOfPTagInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><p>Foo
|
||||
|
||||
@@ -209,7 +230,8 @@ Bar</p></div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testSplitUpInlineNodesInPTagInBlockNode() {
|
||||
public function testSplitUpInlineNodesInPTagInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><p><b>Foo</b>
|
||||
|
||||
@@ -220,11 +242,13 @@ Bar</p></div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testNoParagraphSingleInlineNodeInBlockNode() {
|
||||
public function testNoParagraphSingleInlineNodeInBlockNode()
|
||||
{
|
||||
$this->assertResult( '<div><b>Foo</b></div>' );
|
||||
}
|
||||
|
||||
function testParagraphInBlockquote() {
|
||||
public function testParagraphInBlockquote()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<blockquote>Par1
|
||||
|
||||
@@ -235,7 +259,8 @@ Par2</blockquote>',
|
||||
);
|
||||
}
|
||||
|
||||
function testNoParagraphBetweenListItem() {
|
||||
public function testNoParagraphBetweenListItem()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<ul><li>Foo</li>
|
||||
|
||||
@@ -243,7 +268,8 @@ Par2</blockquote>',
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphSingleElementWithSurroundingSpace() {
|
||||
public function testParagraphSingleElementWithSurroundingSpace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>
|
||||
|
||||
@@ -258,7 +284,8 @@ Bar
|
||||
);
|
||||
}
|
||||
|
||||
function testIgnoreExtraSpaceWithLeadingInlineNode() {
|
||||
public function testIgnoreExtraSpaceWithLeadingInlineNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>Par1</b>a
|
||||
|
||||
@@ -271,7 +298,8 @@ Par2',
|
||||
);
|
||||
}
|
||||
|
||||
function testAbsorbExtraEndingPTag() {
|
||||
public function testAbsorbExtraEndingPTag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -282,7 +310,8 @@ Par2</p>',
|
||||
);
|
||||
}
|
||||
|
||||
function testAbsorbExtraEndingDivTag() {
|
||||
public function testAbsorbExtraEndingDivTag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -293,7 +322,8 @@ Par2</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testDoNotParagraphSingleSurroundingSpaceInBlockNode() {
|
||||
public function testDoNotParagraphSingleSurroundingSpaceInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>
|
||||
Par1
|
||||
@@ -301,7 +331,8 @@ Par1
|
||||
);
|
||||
}
|
||||
|
||||
function testBlockNodeTextDelimeterInBlockNode() {
|
||||
public function testBlockNodeTextDelimeterInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>Par1
|
||||
|
||||
@@ -312,14 +343,16 @@ Par1
|
||||
);
|
||||
}
|
||||
|
||||
function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode() {
|
||||
public function testBlockNodeTextDelimeterWithoutDoublespaceInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>Par1
|
||||
<div>Par2</div></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testBlockNodeTextDelimeterWithoutDoublespace() {
|
||||
public function testBlockNodeTextDelimeterWithoutDoublespace()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
<div>Par2</div>',
|
||||
@@ -330,7 +363,8 @@ Par1
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoParagraphsOfTextAndInlineNode() {
|
||||
public function testTwoParagraphsOfTextAndInlineNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'Par1
|
||||
|
||||
@@ -341,32 +375,37 @@ Par1
|
||||
);
|
||||
}
|
||||
|
||||
function testLeadingInlineNodeParagraph() {
|
||||
public function testLeadingInlineNodeParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<img /> Foo',
|
||||
'<p><img /> Foo</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTrailingInlineNodeParagraph() {
|
||||
public function testTrailingInlineNodeParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<li>Foo <a>bar</a></li>'
|
||||
);
|
||||
}
|
||||
|
||||
function testTwoInlineNodeParagraph() {
|
||||
public function testTwoInlineNodeParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<li><b>baz</b><a>bar</a></li>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNoParagraphTrailingBlockNodeInBlockNode() {
|
||||
public function testNoParagraphTrailingBlockNodeInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><div>asdf</div><b>asdf</b></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode() {
|
||||
public function testParagraphTrailingBlockNodeWithDoublespaceInBlockNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><div>asdf</div>
|
||||
|
||||
@@ -377,14 +416,16 @@ Par1
|
||||
);
|
||||
}
|
||||
|
||||
function testParagraphTwoInlineNodesAndWhitespaceNode() {
|
||||
public function testParagraphTwoInlineNodesAndWhitespaceNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>One</b> <i>Two</i>',
|
||||
'<p><b>One</b> <i>Two</i></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNoParagraphWithInlineRootNode() {
|
||||
public function testNoParagraphWithInlineRootNode()
|
||||
{
|
||||
$this->config->set('HTML.Parent', 'span');
|
||||
$this->assertResult(
|
||||
'Par
|
||||
@@ -393,13 +434,15 @@ Par2'
|
||||
);
|
||||
}
|
||||
|
||||
function testInlineAndBlockTagInDivNoParagraph() {
|
||||
public function testInlineAndBlockTagInDivNoParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><code>bar</code> mmm <pre>asdf</pre></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testInlineAndBlockTagInDivNeedingParagraph() {
|
||||
public function testInlineAndBlockTagInDivNeedingParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><code>bar</code> mmm
|
||||
|
||||
@@ -410,7 +453,8 @@ Par2'
|
||||
);
|
||||
}
|
||||
|
||||
function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph() {
|
||||
public function testTextInlineNodeTextThenDoubleNewlineNeedsParagraph()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>asdf <code>bar</code> mmm
|
||||
|
||||
@@ -421,7 +465,8 @@ Par2'
|
||||
);
|
||||
}
|
||||
|
||||
function testUpcomingTokenHasNewline() {
|
||||
public function testUpcomingTokenHasNewline()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>Test<b>foo</b>bar<b>bing</b>bang
|
||||
|
||||
@@ -432,7 +477,8 @@ boo</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testEmptyTokenAtEndOfDiv() {
|
||||
public function testEmptyTokenAtEndOfDiv()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><p>foo</p>
|
||||
</div>',
|
||||
@@ -441,7 +487,8 @@ boo</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testEmptyDoubleLineTokenAtEndOfDiv() {
|
||||
public function testEmptyDoubleLineTokenAtEndOfDiv()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><p>foo</p>
|
||||
|
||||
@@ -452,26 +499,31 @@ boo</div>',
|
||||
);
|
||||
}
|
||||
|
||||
function testTextState11Root() {
|
||||
public function testTextState11Root()
|
||||
{
|
||||
$this->assertResult('<div></div> ');
|
||||
}
|
||||
|
||||
function testTextState11Element() {
|
||||
public function testTextState11Element()
|
||||
{
|
||||
$this->assertResult(
|
||||
"<div><div></div>
|
||||
|
||||
</div>");
|
||||
}
|
||||
|
||||
function testTextStateLikeElementState111NoWhitespace() {
|
||||
public function testTextStateLikeElementState111NoWhitespace()
|
||||
{
|
||||
$this->assertResult('<div><p>P</p>Boo</div>', '<div><p>P</p>Boo</div>');
|
||||
}
|
||||
|
||||
function testElementState111NoWhitespace() {
|
||||
public function testElementState111NoWhitespace()
|
||||
{
|
||||
$this->assertResult('<div><p>P</p><b>Boo</b></div>', '<div><p>P</p><b>Boo</b></div>');
|
||||
}
|
||||
|
||||
function testElementState133() {
|
||||
public function testElementState133()
|
||||
{
|
||||
$this->assertResult(
|
||||
"<div><b>B</b><pre>Ba</pre>
|
||||
|
||||
@@ -482,13 +534,15 @@ Bar</div>",
|
||||
);
|
||||
}
|
||||
|
||||
function testElementState22() {
|
||||
public function testElementState22()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<ul><li>foo</li></ul>'
|
||||
);
|
||||
}
|
||||
|
||||
function testElementState311() {
|
||||
public function testElementState311()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p>Foo</p><b>Bar</b>',
|
||||
'<p>Foo</p>
|
||||
@@ -497,20 +551,23 @@ Bar</div>",
|
||||
);
|
||||
}
|
||||
|
||||
function testAutoClose() {
|
||||
public function testAutoClose()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p></p>
|
||||
<hr />'
|
||||
);
|
||||
}
|
||||
|
||||
function testErrorNeeded() {
|
||||
public function testErrorNeeded()
|
||||
{
|
||||
$this->config->set('HTML.Allowed', 'b');
|
||||
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
|
||||
$this->assertResult('<b>foobar</b>');
|
||||
}
|
||||
|
||||
function testParentElement() {
|
||||
public function testParentElement()
|
||||
{
|
||||
$this->config->set('HTML.Allowed', 'p,ul,li');
|
||||
$this->assertResult('Foo<ul><li>Bar</li></ul>', "<p>Foo</p>\n\n<ul><li>Bar</li></ul>");
|
||||
}
|
||||
|
@@ -3,25 +3,29 @@
|
||||
class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('AutoFormat.DisplayLinkURI', true);
|
||||
}
|
||||
|
||||
function testBasicLink() {
|
||||
public 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() {
|
||||
public function testEmptyLink()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<a>Don\'t go here!</a>',
|
||||
'<a>Don\'t go here!</a>'
|
||||
);
|
||||
}
|
||||
function testEmptyText() {
|
||||
public function testEmptyText()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<a href="http://malware.example.com"></a>',
|
||||
'<a></a> (http://malware.example.com)'
|
||||
|
@@ -3,45 +3,52 @@
|
||||
class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('AutoFormat.Linkify', true);
|
||||
}
|
||||
|
||||
function testLinkifyURLInRootNode() {
|
||||
public function testLinkifyURLInRootNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'http://example.com',
|
||||
'<a href="http://example.com">http://example.com</a>'
|
||||
);
|
||||
}
|
||||
|
||||
function testLinkifyURLInInlineNode() {
|
||||
public function testLinkifyURLInInlineNode()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>http://example.com</b>',
|
||||
'<b><a href="http://example.com">http://example.com</a></b>'
|
||||
);
|
||||
}
|
||||
|
||||
function testBasicUsageCase() {
|
||||
public 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() {
|
||||
public function testIgnoreURLInATag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<a>http://example.com/</a>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNeeded() {
|
||||
public function testNeeded()
|
||||
{
|
||||
$this->config->set('HTML.Allowed', 'b');
|
||||
$this->expectError('Cannot enable Linkify injector because a is not allowed');
|
||||
$this->assertResult('http://example.com/');
|
||||
}
|
||||
|
||||
function testExcludes() {
|
||||
public function testExcludes()
|
||||
{
|
||||
$this->assertResult('<a><span>http://example.com</span></a>');
|
||||
}
|
||||
|
||||
|
@@ -3,52 +3,61 @@
|
||||
class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('AutoFormat.PurifierLinkify', true);
|
||||
$this->config->set('AutoFormat.PurifierLinkify.DocURL', '#%s');
|
||||
}
|
||||
|
||||
function testNoTriggerCharacer() {
|
||||
public function testNoTriggerCharacer()
|
||||
{
|
||||
$this->assertResult('Foobar');
|
||||
}
|
||||
|
||||
function testTriggerCharacterInIrrelevantContext() {
|
||||
public function testTriggerCharacterInIrrelevantContext()
|
||||
{
|
||||
$this->assertResult('20% off!');
|
||||
}
|
||||
|
||||
function testPreserveNamespace() {
|
||||
public function testPreserveNamespace()
|
||||
{
|
||||
$this->assertResult('%Core namespace (not recognized)');
|
||||
}
|
||||
|
||||
function testLinkifyBasic() {
|
||||
public function testLinkifyBasic()
|
||||
{
|
||||
$this->assertResult(
|
||||
'%Namespace.Directive',
|
||||
'<a href="#Namespace.Directive">%Namespace.Directive</a>'
|
||||
);
|
||||
}
|
||||
|
||||
function testLinkifyWithAdjacentTextNodes() {
|
||||
public function testLinkifyWithAdjacentTextNodes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'This %Namespace.Directive thing',
|
||||
'This <a href="#Namespace.Directive">%Namespace.Directive</a> thing'
|
||||
);
|
||||
}
|
||||
|
||||
function testLinkifyInBlock() {
|
||||
public function testLinkifyInBlock()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div>This %Namespace.Directive thing</div>',
|
||||
'<div>This <a href="#Namespace.Directive">%Namespace.Directive</a> thing</div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testPreserveInATag() {
|
||||
public function testPreserveInATag()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<a>%Namespace.Directive</a>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNeeded() {
|
||||
public function testNeeded()
|
||||
{
|
||||
$this->config->set('HTML.Allowed', 'b');
|
||||
$this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
|
||||
$this->assertResult('%Namespace.Directive');
|
||||
|
@@ -3,73 +3,89 @@
|
||||
class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
public function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('AutoFormat.RemoveEmpty', true);
|
||||
}
|
||||
|
||||
function testPreserve() {
|
||||
public function testPreserve()
|
||||
{
|
||||
$this->assertResult('<b>asdf</b>');
|
||||
}
|
||||
|
||||
function testRemove() {
|
||||
public function testRemove()
|
||||
{
|
||||
$this->assertResult('<b></b>', '');
|
||||
}
|
||||
|
||||
function testRemoveWithSpace() {
|
||||
public function testRemoveWithSpace()
|
||||
{
|
||||
$this->assertResult('<b> </b>', '');
|
||||
}
|
||||
|
||||
function testRemoveWithAttr() {
|
||||
public function testRemoveWithAttr()
|
||||
{
|
||||
$this->assertResult('<b class="asdf"></b>', '');
|
||||
}
|
||||
|
||||
function testRemoveIdAndName() {
|
||||
public function testRemoveIdAndName()
|
||||
{
|
||||
$this->assertResult('<a id="asdf" name="asdf"></a>', '');
|
||||
}
|
||||
|
||||
function testPreserveColgroup() {
|
||||
public function testPreserveColgroup()
|
||||
{
|
||||
$this->assertResult('<colgroup></colgroup>');
|
||||
}
|
||||
|
||||
function testPreserveId() {
|
||||
public function testPreserveId()
|
||||
{
|
||||
$this->config->set('Attr.EnableID', true);
|
||||
$this->assertResult('<a id="asdf"></a>');
|
||||
}
|
||||
|
||||
function testPreserveName() {
|
||||
public function testPreserveName()
|
||||
{
|
||||
$this->config->set('Attr.EnableID', true);
|
||||
$this->assertResult('<a name="asdf"></a>');
|
||||
}
|
||||
|
||||
function testRemoveNested() {
|
||||
public function testRemoveNested()
|
||||
{
|
||||
$this->assertResult('<b><i></i></b>', '');
|
||||
}
|
||||
|
||||
function testRemoveNested2() {
|
||||
public function testRemoveNested2()
|
||||
{
|
||||
$this->assertResult('<b><i><u></u></i></b>', '');
|
||||
}
|
||||
|
||||
function testRemoveNested3() {
|
||||
public function testRemoveNested3()
|
||||
{
|
||||
$this->assertResult('<b> <i> <u> </u> </i> </b>', '');
|
||||
}
|
||||
|
||||
function testRemoveNbsp() {
|
||||
public function testRemoveNbsp()
|
||||
{
|
||||
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
||||
$this->assertResult('<b> </b>', '');
|
||||
}
|
||||
|
||||
function testRemoveNbspMix() {
|
||||
public function testRemoveNbspMix()
|
||||
{
|
||||
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
||||
$this->assertResult('<b> </b>', '');
|
||||
}
|
||||
|
||||
function testDontRemoveNbsp() {
|
||||
public function testDontRemoveNbsp()
|
||||
{
|
||||
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
||||
$this->assertResult('<td> </b>', "<td>\xC2\xA0</td>");
|
||||
}
|
||||
|
||||
function testRemoveNbspExceptionsSpecial() {
|
||||
public function testRemoveNbspExceptionsSpecial()
|
||||
{
|
||||
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp', true);
|
||||
$this->config->set('AutoFormat.RemoveEmpty.RemoveNbsp.Exceptions', 'b');
|
||||
$this->assertResult('<b> </b>', "<b>\xC2\xA0</b>");
|
||||
|
@@ -2,34 +2,39 @@
|
||||
|
||||
class HTMLPurifier_Injector_RemoveSpansWithoutAttributesTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
function setup() {
|
||||
public function setup()
|
||||
{
|
||||
parent::setup();
|
||||
$this->config->set('HTML.Allowed', 'span[class],div,p,strong,em');
|
||||
$this->config->set('AutoFormat.RemoveSpansWithoutAttributes', true);
|
||||
}
|
||||
|
||||
function testSingleSpan() {
|
||||
public function testSingleSpan()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<span>foo</span>',
|
||||
'foo'
|
||||
);
|
||||
}
|
||||
|
||||
function testSingleSpanWithAttributes() {
|
||||
public function testSingleSpanWithAttributes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<span class="bar">foo</span>',
|
||||
'<span class="bar">foo</span>'
|
||||
);
|
||||
}
|
||||
|
||||
function testSingleNestedSpan() {
|
||||
public function testSingleNestedSpan()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p><span>foo</span></p>',
|
||||
'<p>foo</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testSingleNestedSpanWithAttributes() {
|
||||
public function testSingleNestedSpanWithAttributes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p><span class="bar">foo</span></p>',
|
||||
'<p><span class="bar">foo</span></p>'
|
||||
@@ -37,49 +42,56 @@ class HTMLPurifier_Injector_RemoveSpansWithoutAttributesTest extends HTMLPurifie
|
||||
}
|
||||
|
||||
|
||||
function testSpanWithChildren() {
|
||||
public function testSpanWithChildren()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<span>foo <strong>bar</strong> <em>baz</em></span>',
|
||||
'foo <strong>bar</strong> <em>baz</em>'
|
||||
);
|
||||
}
|
||||
|
||||
function testSpanWithSiblings() {
|
||||
public function testSpanWithSiblings()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p>before <span>inside</span> <strong>after</strong></p>',
|
||||
'<p>before inside <strong>after</strong></p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNestedSpanWithSiblingsAndChildren() {
|
||||
public function testNestedSpanWithSiblingsAndChildren()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p>a <span>b <em>c</em> d</span> e</p>',
|
||||
'<p>a b <em>c</em> d e</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNestedSpansWithoutAttributes() {
|
||||
public function testNestedSpansWithoutAttributes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<span>one<span>two<span>three</span></span></span>',
|
||||
'onetwothree'
|
||||
);
|
||||
}
|
||||
|
||||
function testDeeplyNestedSpan() {
|
||||
public function testDeeplyNestedSpan()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<div><div><div><span class="a">a <span>b</span> c</span></div></div></div>',
|
||||
'<div><div><div><span class="a">a b c</span></div></div></div>'
|
||||
);
|
||||
}
|
||||
|
||||
function testSpanWithInvalidAttributes() {
|
||||
public function testSpanWithInvalidAttributes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p><span snorkel buzzer="emu">foo</span></p>',
|
||||
'<p>foo</p>'
|
||||
);
|
||||
}
|
||||
|
||||
function testNestedAlternateSpans() {
|
||||
public function testNestedAlternateSpans()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<span>a <span class="x">b <span>c <span class="y">d <span>e <span class="z">f
|
||||
</span></span></span></span></span></span>',
|
||||
@@ -88,7 +100,8 @@ class HTMLPurifier_Injector_RemoveSpansWithoutAttributesTest extends HTMLPurifie
|
||||
);
|
||||
}
|
||||
|
||||
function testSpanWithSomeInvalidAttributes() {
|
||||
public function testSpanWithSomeInvalidAttributes()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<p><span buzzer="emu" class="bar">foo</span></p>',
|
||||
'<p><span class="bar">foo</span></p>'
|
||||
|
@@ -8,75 +8,86 @@
|
||||
class HTMLPurifier_Injector_SafeObjectTest extends HTMLPurifier_InjectorHarness
|
||||
{
|
||||
|
||||
function setup() {
|
||||
public 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() {
|
||||
public function testPreserve()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<b>asdf</b>'
|
||||
);
|
||||
}
|
||||
|
||||
function testRemoveStrayParam() {
|
||||
public function testRemoveStrayParam()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<param />',
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
function testEditObjectParam() {
|
||||
public function testEditObjectParam()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<object></object>',
|
||||
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIgnoreStrayParam() {
|
||||
public function testIgnoreStrayParam()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<object><param /></object>',
|
||||
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIgnoreDuplicates() {
|
||||
public function testIgnoreDuplicates()
|
||||
{
|
||||
$this->assertResult(
|
||||
'<object><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /></object>'
|
||||
);
|
||||
}
|
||||
|
||||
function testIgnoreBogusData() {
|
||||
public 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() {
|
||||
public 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() {
|
||||
public 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() {
|
||||
public 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() {
|
||||
public 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>'
|
||||
|
Reference in New Issue
Block a user