obj = new HTMLPurifier_Strategy_ValidateAttributes(); } function testEmpty() { $this->assertResult(''); } function testIDs() { $this->assertResult( '
Kill the ID.
', '
Kill the ID.
' ); $this->assertResult('
Preserve the ID.
', true, array('HTML.EnableAttrID' => true)); $this->assertResult( '
Kill the ID.
', '
Kill the ID.
', array('HTML.EnableAttrID' => true) ); // test id accumulator $this->assertResult( '
Valid
Invalid
', '
Valid
Invalid
', array('HTML.EnableAttrID' => true) ); $this->assertResult( 'Bad dir.', 'Bad dir.' ); // test attribute key case sensitivity $this->assertResult( '
Convert ID to lowercase.
', '
Convert ID to lowercase.
', array('HTML.EnableAttrID' => true) ); // test simple attribute substitution $this->assertResult( '
Trim whitespace.
', '
Trim whitespace.
', array('HTML.EnableAttrID' => true) ); // test configuration id blacklist $this->assertResult( '
Invalid
', '
Invalid
', array( 'Attr.IDBlacklist' => array('invalid'), 'HTML.EnableAttrID' => true ) ); // name rewritten as id $this->assertResult( '', '', array('HTML.EnableAttrID' => true) ); } function testClasses() { $this->assertResult('
Valid
'); $this->assertResult( '
Keep valid.
', '
Keep valid.
' ); } function testTitle() { $this->assertResult( 'PHP' ); } function testLang() { $this->assertResult( 'La soupe.', 'La soupe.' ); // test only xml:lang for XHTML 1.1 $this->assertResult( 'asdf', 'asdf', array('HTML.Doctype' => 'XHTML 1.1') ); } function testAlign() { $this->assertResult( '

Centered Headline

', '

Centered Headline

' ); $this->assertResult( '

Right-aligned Headline

', '

Right-aligned Headline

' ); $this->assertResult( '

Left-aligned Headline

', '

Left-aligned Headline

' ); $this->assertResult( '

Justified Paragraph

', '

Justified Paragraph

' ); $this->assertResult( '

Invalid Headline

', '

Invalid Headline

' ); } function testTable() { $this->assertResult( '
Fiddly name Super-duper-price
Carrot Humungous $500.23
Taken off the market
' ); // test col.span is non-zero $this->assertResult( '', '' ); // lengths $this->assertResult( '
', '
' ); // td boolean transformation $this->assertResult( '', '' ); // caption align transformation $this->assertResult( '', '' ); $this->assertResult( '', '' ); $this->assertResult( '', '' ); $this->assertResult( '', '' ); $this->assertResult( '', '' ); // align transformation $this->assertResult( '', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); } function testURI() { $this->assertResult('Google'); // test invalid URI $this->assertResult( 'Google', 'Google' ); } function testImg() { // (this should never happen, as RemoveForeignElements // should have removed the offending image tag) $this->assertResult( '', 'Invalid image' ); $this->assertResult( '', 'foobar.jpg' ); $this->assertResult( 'pretty picture', 'pretty picture' ); // mailto in image is not allowed $this->assertResult( '', 'Invalid image' ); // align transformation $this->assertResult( 'foobar', 'foobar' ); $this->assertResult( 'foobar', 'foobar' ); $this->assertResult( 'foobar', 'foobar' ); $this->assertResult( 'foobar', 'foobar' ); $this->assertResult( 'foobar', 'foobar' ); $this->assertResult( 'foobar', 'foobar' ); } function testBdo() { // test required attributes for bdo $this->assertResult( 'Go left.', 'Go left.' ); $this->assertResult( 'Invalid value!', 'Invalid value!' ); } function testDir() { // see testBdo, behavior is subtly different $this->assertResult( 'Invalid value!', 'Invalid value!' ); } function testLinks() { // link types $this->assertResult( '', true, array('Attr.AllowedRel' => 'nofollow') ); // link targets $this->assertResult( '', true, array('Attr.AllowedFrameTargets' => '_top') ); $this->assertResult( '', '' ); $this->assertResult( '', '', array('Attr.AllowedFrameTargets' => '_top', 'HTML.Strict' => true) ); } function testBorder() { // border $this->assertResult( 'foo', 'foo', array('Attr.AllowedRel' => 'nofollow') ); } function testHr() { $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); // align transformation $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); } function testBr() { // br clear transformation $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( // test both? '
', '
' ); $this->assertResult( '
', '
' ); $this->assertResult( '
', '
' ); } function testListTypeTransform() { // ul $this->assertResult( '