1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-08-06 14:16:32 +02:00

Convert all to new configuration get/set format.

Signed-off-by: Edward Z. Yang <edwardzyang@thewritingpot.com>
This commit is contained in:
Edward Z. Yang
2009-02-19 19:17:49 -05:00
parent b107eec452
commit 86ca784da3
106 changed files with 504 additions and 815 deletions

View File

@@ -116,7 +116,7 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
}
function testProprietary() {
$this->config->set('CSS', 'Proprietary', true);
$this->config->set('CSS.Proprietary', true);
$this->assertDef('scrollbar-arrow-color:#ff0;');
$this->assertDef('scrollbar-base-color:#ff6347;');
@@ -133,12 +133,12 @@ class HTMLPurifier_AttrDef_CSSTest extends HTMLPurifier_AttrDefHarness
}
function testImportant() {
$this->config->set('CSS', 'AllowImportant', true);
$this->config->set('CSS.AllowImportant', true);
$this->assertDef('float:left !important;');
}
function testTricky() {
$this->config->set('CSS', 'AllowTricky', true);
$this->config->set('CSS.AllowTricky', true);
$this->assertDef('display:none;');
$this->assertDef('visibility:visible;');
$this->assertDef('overflow:scroll;');

View File

@@ -16,7 +16,7 @@ class HTMLPurifier_AttrDef_HTML_FrameTargetTest extends HTMLPurifier_AttrDefHarn
}
function test() {
$this->config->set('Attr', 'AllowedFrameTargets', 'foo,_blank');
$this->config->set('Attr.AllowedFrameTargets', 'foo,_blank');
$this->assertDef('', false);
$this->assertDef('foo');
$this->assertDef('_blank');

View File

@@ -8,7 +8,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
$id_accumulator = new HTMLPurifier_IDAccumulator();
$this->context->register('IDAccumulator', $id_accumulator);
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Attr.EnableID', true);
$this->def = new HTMLPurifier_AttrDef_HTML_ID();
}
@@ -37,7 +37,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testPrefix() {
$this->config->set('Attr', 'IDPrefix', 'user_');
$this->config->set('Attr.IDPrefix', 'user_');
$this->assertDef('alpha', 'user_alpha');
$this->assertDef('<asa', false);
@@ -52,8 +52,8 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testTwoPrefixes() {
$this->config->set('Attr', 'IDPrefix', 'user_');
$this->config->set('Attr', 'IDPrefixLocal', 'story95_');
$this->config->set('Attr.IDPrefix', 'user_');
$this->config->set('Attr.IDPrefixLocal', 'story95_');
$this->assertDef('alpha', 'user_story95_alpha');
$this->assertDef('<asa', false);
@@ -66,8 +66,8 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testLocalPrefixWithoutMainPrefix() {
// no effect when IDPrefix isn't set
$this->config->set('Attr', 'IDPrefix', '');
$this->config->set('Attr', 'IDPrefixLocal', 'story95_');
$this->config->set('Attr.IDPrefix', '');
$this->config->set('Attr.IDPrefixLocal', 'story95_');
$this->expectError('%Attr.IDPrefixLocal cannot be used unless '.
'%Attr.IDPrefix is set');
$this->assertDef('amherst');
@@ -96,7 +96,7 @@ class HTMLPurifier_AttrDef_HTML_IDTest extends HTMLPurifier_AttrDefHarness
function testRegexp() {
$this->config->set('Attr', 'IDBlacklistRegexp', '/^g_/');
$this->config->set('Attr.IDBlacklistRegexp', '/^g_/');
$this->assertDef('good_id');
$this->assertDef('g_bad_id', false);

View File

@@ -6,7 +6,7 @@ class HTMLPurifier_AttrDef_HTML_LinkTypesTest extends HTMLPurifier_AttrDefHarnes
function testNull() {
$this->def = new HTMLPurifier_AttrDef_HTML_LinkTypes('rel');
$this->config->set('Attr', 'AllowedRel', array('nofollow', 'foo'));
$this->config->set('Attr.AllowedRel', array('nofollow', 'foo'));
$this->assertDef('', false);
$this->assertDef('nofollow', true);

View File

@@ -49,7 +49,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
}
function testConfigMunge() {
$this->config->set('URI', 'Munge', 'http://www.google.com/url?q=%s');
$this->config->set('URI.Munge', 'http://www.google.com/url?q=%s');
$this->assertDef(
'http://www.example.com/',
'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F'
@@ -77,7 +77,7 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
function testURIDefinitionValidation() {
$parser = new HTMLPurifier_URIParser();
$uri = $parser->parse('http://example.com');
$this->config->set('URI', 'DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation');
$this->config->set('URI.DefinitionID', 'HTMLPurifier_AttrDef_URITest->testURIDefinitionValidation');
generate_mock_once('HTMLPurifier_URIDefinition');
$uri_def = new HTMLPurifier_URIDefinitionMock();
@@ -121,8 +121,8 @@ class HTMLPurifier_AttrDef_URITest extends HTMLPurifier_AttrDefHarness
/*
function test_validate_configWhitelist() {
$this->config->set('URI', 'HostPolicy', 'DenyAll');
$this->config->set('URI', 'HostWhitelist', array(null, 'google.com'));
$this->config->set('URI.HostPolicy', 'DenyAll');
$this->config->set('URI.HostWhitelist', array(null, 'google.com'));
$this->assertDef('http://example.com/fo/google.com', false);
$this->assertDef('server.txt');

View File

@@ -17,7 +17,7 @@ class HTMLPurifier_AttrTransform_BdoDirTest extends HTMLPurifier_AttrTransformHa
}
function testAlternateDefault() {
$this->config->set('Attr', 'DefaultTextDir', 'rtl');
$this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult(
array(),
array('dir' => 'rtl')

View File

@@ -9,7 +9,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
}
function testAddMissingAttr() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
array(),
array('src' => '', 'alt' => 'Invalid image')
@@ -17,10 +17,10 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
}
function testAlternateDefaults() {
$this->config->set('Attr', 'DefaultInvalidImage', 'blank.png');
$this->config->set('Attr', 'DefaultInvalidImageAlt', 'Pawned!');
$this->config->set('Attr', 'DefaultImageAlt', 'not pawned');
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Attr.DefaultInvalidImage', 'blank.png');
$this->config->set('Attr.DefaultInvalidImageAlt', 'Pawned!');
$this->config->set('Attr.DefaultImageAlt', 'not pawned');
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
array(),
array('src' => 'blank.png', 'alt' => 'Pawned!')
@@ -35,7 +35,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
}
function testAddDefaultSrc() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
array('alt' => 'intrigue'),
array('alt' => 'intrigue', 'src' => '')
@@ -43,7 +43,7 @@ class HTMLPurifier_AttrTransform_ImgRequiredTest extends HTMLPurifier_AttrTransf
}
function testAddDefaultAlt() {
$this->config->set('Attr', 'DefaultImageAlt', 'default');
$this->config->set('Attr.DefaultImageAlt', 'default');
$this->assertResult(
array('src' => ''),
array('src' => '', 'alt' => 'default')

View File

@@ -18,7 +18,7 @@ class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
}
function testAttributesTransformedGlobalPre() {
$this->config->set('HTML', 'DefinitionID',
$this->config->set('HTML.DefinitionID',
'HTMLPurifier_AttrValidator_ErrorsTest::testAttributesTransformedGlobalPre');
$def = $this->config->getHTMLDefinition(true);
generate_mock_once('HTMLPurifier_AttrTransform');
@@ -39,7 +39,7 @@ class HTMLPurifier_AttrValidator_ErrorsTest extends HTMLPurifier_ErrorsHarness
}
function testAttributesTransformedLocalPre() {
$this->config->set('HTML', 'TidyLevel', 'heavy');
$this->config->set('HTML.TidyLevel', 'heavy');
$input = array('align' => 'right');
$output = array('style' => 'text-align:right;');
$token = new HTMLPurifier_Token_Start('p', $input, 1);

View File

@@ -62,7 +62,7 @@ class HTMLPurifier_ChildDef_RequiredTest extends HTMLPurifier_ChildDefHarness
function testPCDATAAllowedWithEscaping() {
$this->obj = new HTMLPurifier_ChildDef_Required('#PCDATA | b');
$this->config->set('Core', 'EscapeInvalidChildren', true);
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult(
'Out <b>Bold text</b><img />',
'Out <b>Bold text</b>&lt;img /&gt;'

View File

@@ -65,7 +65,7 @@ extends HTMLPurifier_ChildDefHarness
}
function testAlternateWrapper() {
$this->config->set('HTML', 'BlockWrapper', 'div');
$this->config->set('HTML.BlockWrapper', 'div');
$this->assertResult('Needs wrap', '<div>Needs wrap</div>');
}
@@ -73,8 +73,8 @@ extends HTMLPurifier_ChildDefHarness
function testError() {
$this->expectError('Cannot use non-block element as block wrapper');
$this->obj = new HTMLPurifier_ChildDef_StrictBlockquote('div | p');
$this->config->set('HTML', 'BlockWrapper', 'dav');
$this->config->set('Cache', 'DefinitionImpl', null);
$this->config->set('HTML.BlockWrapper', 'dav');
$this->config->set('Cache.DefinitionImpl', null);
$this->assertResult('Needs wrap', '<p>Needs wrap</p>');
}

View File

@@ -43,12 +43,12 @@ class HTMLPurifier_ChildDef_TableTest extends HTMLPurifier_ChildDefHarness
}
function testStickyWhitespaceOnTr() {
$this->config->set('Output', 'Newline', "\n");
$this->config->set('Output.Newline', "\n");
$this->assertResult("\n <tr />\n <tr />\n ");
}
function testStickyWhitespaceOnTSection() {
$this->config->set('Output', 'Newline', "\n");
$this->config->set('Output.Newline', "\n");
$this->assertResult(
"\n\t<tbody />\n\t\t<tfoot />\n\t\t\t",
"\n\t\t<tfoot />\n\t<tbody />\n\t\t\t"

View File

@@ -25,48 +25,49 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
// test default value retrieval
$this->assertIdentical($config->get('Element', 'Abbr'), 'H');
$this->assertIdentical($config->get('Element', 'Name'), 'hydrogen');
$this->assertIdentical($config->get('Element', 'Number'), 1);
$this->assertIdentical($config->get('Element', 'Mass'), 1.00794);
$this->assertIdentical($config->get('Element', 'Radioactive'), false);
$this->assertIdentical($config->get('Element', 'Isotopes'), array(1 => true, 2 => true, 3 => true));
$this->assertIdentical($config->get('Element', 'Traits'), array('nonmetallic', 'odorless', 'flammable'));
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium'));
$this->assertIdentical($config->get('Element', 'Object'), new stdClass());
$this->assertIdentical($config->get('Element.Abbr'), 'H');
$this->assertIdentical($config->get('Element.Name'), 'hydrogen');
$this->assertIdentical($config->get('Element.Number'), 1);
$this->assertIdentical($config->get('Element.Mass'), 1.00794);
$this->assertIdentical($config->get('Element.Radioactive'), false);
$this->assertIdentical($config->get('Element.Isotopes'), array(1 => true, 2 => true, 3 => true));
$this->assertIdentical($config->get('Element.Traits'), array('nonmetallic', 'odorless', 'flammable'));
$this->assertIdentical($config->get('Element.IsotopeNames'), array(1 => 'protium', 2 => 'deuterium', 3 => 'tritium'));
$this->assertIdentical($config->get('Element.Object'), new stdClass());
// test setting values
$config->set('Element', 'Abbr', 'Pu');
$config->set('Element', 'Name', 'PLUTONIUM'); // test decaps
$config->set('Element', 'Number', '94'); // test parsing
$config->set('Element', 'Mass', '244.'); // test parsing
$config->set('Element', 'Radioactive', true);
$config->set('Element', 'Isotopes', array(238, 239)); // test inversion
$config->set('Element', 'Traits', 'nuclear, heavy, actinide'); // test parsing
$config->set('Element', 'IsotopeNames', array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$config->set('Element', 'Object', false); // unmodeled
$config->set('Element.Abbr', 'Pu');
$config->set('Element.Name', 'PLUTONIUM'); // test decaps
$config->set('Element.Number', '94'); // test parsing
$config->set('Element.Mass', '244.'); // test parsing
$config->set('Element.Radioactive', true);
$config->set('Element.Isotopes', array(238, 239)); // test inversion
$config->set('Element.Traits', 'nuclear, heavy, actinide'); // test parsing
$config->set('Element.IsotopeNames', array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$config->set('Element.Object', false); // unmodeled
$this->expectError('Cannot set undefined directive Element.Metal to value');
$config->set('Element', 'Metal', true);
$config->set('Element.Metal', true);
$this->expectError('Value for Element.Radioactive is of invalid type, should be bool');
$config->set('Element', 'Radioactive', 'very');
$config->set('Element.Radioactive', 'very');
// test value retrieval
$this->assertIdentical($config->get('Element', 'Abbr'), 'Pu');
$this->assertIdentical($config->get('Element', 'Name'), 'plutonium');
$this->assertIdentical($config->get('Element', 'Number'), 94);
$this->assertIdentical($config->get('Element', 'Mass'), 244.);
$this->assertIdentical($config->get('Element', 'Radioactive'), true);
$this->assertIdentical($config->get('Element', 'Isotopes'), array(238 => true, 239 => true));
$this->assertIdentical($config->get('Element', 'Traits'), array('nuclear', 'heavy', 'actinide'));
$this->assertIdentical($config->get('Element', 'IsotopeNames'), array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$this->assertIdentical($config->get('Element', 'Object'), false);
$this->assertIdentical($config->get('Element.Abbr'), 'Pu');
$this->assertIdentical($config->get('Element.Name'), 'plutonium');
$this->assertIdentical($config->get('Element.Number'), 94);
$this->assertIdentical($config->get('Element.Mass'), 244.);
$this->assertIdentical($config->get('Element.Radioactive'), true);
$this->assertIdentical($config->get('Element.Isotopes'), array(238 => true, 239 => true));
$this->assertIdentical($config->get('Element.Traits'), array('nuclear', 'heavy', 'actinide'));
$this->assertIdentical($config->get('Element.IsotopeNames'), array(238 => 'Plutonium-238', 239 => 'Plutonium-239'));
$this->assertIdentical($config->get('Element.Object'), false);
$this->expectError('Cannot retrieve value of undefined directive Element.Metal');
$config->get('Element', 'Metal');
$config->get('Element.Metal');
}
@@ -90,31 +91,32 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
// case sensitive
$config->set('Instrument', 'Manufacturer', 'Vandoren');
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Vandoren');
$config->set('Instrument.Manufacturer', 'Vandoren');
$this->assertIdentical($config->get('Instrument.Manufacturer'), 'Vandoren');
$config->set('Instrument', 'Manufacturer', 'Selmer');
$this->assertIdentical($config->get('Instrument', 'Manufacturer'), 'Conn-Selmer');
$config->set('Instrument.Manufacturer', 'Selmer');
$this->assertIdentical($config->get('Instrument.Manufacturer'), 'Conn-Selmer');
$this->expectError('Value not supported, valid values are: Yamaha, Conn-Selmer, Vandoren, Laubin, Buffet, other');
$config->set('Instrument', 'Manufacturer', 'buffet');
$config->set('Instrument.Manufacturer', 'buffet');
// case insensitive
$config->set('Instrument', 'Family', 'brass');
$this->assertIdentical($config->get('Instrument', 'Family'), 'brass');
$config->set('Instrument.Family', 'brass');
$this->assertIdentical($config->get('Instrument.Family'), 'brass');
$config->set('Instrument', 'Family', 'PERCUSSION');
$this->assertIdentical($config->get('Instrument', 'Family'), 'percussion');
$config->set('Instrument.Family', 'PERCUSSION');
$this->assertIdentical($config->get('Instrument.Family'), 'percussion');
$config->set('Instrument', 'Family', 'synth');
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic');
$config->set('Instrument.Family', 'synth');
$this->assertIdentical($config->get('Instrument.Family'), 'electronic');
$config->set('Instrument', 'Family', 'Synth');
$this->assertIdentical($config->get('Instrument', 'Family'), 'electronic');
$config->set('Instrument.Family', 'Synth');
$this->assertIdentical($config->get('Instrument.Family'), 'electronic');
}
@@ -125,16 +127,17 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
$config->set('ReportCard', 'English', 'B-');
$this->assertIdentical($config->get('ReportCard', 'English'), 'B-');
$config->set('ReportCard.English', 'B-');
$this->assertIdentical($config->get('ReportCard.English'), 'B-');
$config->set('ReportCard', 'English', null); // not yet graded
$this->assertIdentical($config->get('ReportCard', 'English'), null);
$config->set('ReportCard.English', null); // not yet graded
$this->assertIdentical($config->get('ReportCard.English'), null);
// error
$this->expectError('Value for ReportCard.Absences is of invalid type, should be int');
$config->set('ReportCard', 'Absences', null);
$config->set('ReportCard.Absences', null);
}
@@ -145,15 +148,16 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
$this->assertIdentical($config->get('Home', 'Rug'), 3);
$this->assertIdentical($config->get('Home.Rug'), 3);
$this->expectError('Cannot get value from aliased directive, use real name Home.Rug');
$config->get('Home', 'Carpet');
$config->get('Home.Carpet');
$this->expectError('Home.Carpet is an alias, preferred directive name is Home.Rug');
$config->set('Home', 'Carpet', 999);
$this->assertIdentical($config->get('Home', 'Rug'), 999);
$config->set('Home.Carpet', 999);
$this->assertIdentical($config->get('Home.Rug'), 999);
}
@@ -166,6 +170,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
// grab a namespace
$this->assertIdentical(
@@ -193,9 +198,9 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config->loadIni(dirname(__FILE__) . '/ConfigTest-loadIni.ini');
$this->assertIdentical($config->get('Shortcut', 'Copy'), 'q');
$this->assertIdentical($config->get('Shortcut', 'Paste'), 'p');
$this->assertIdentical($config->get('Shortcut', 'Cut'), 't');
$this->assertIdentical($config->get('Shortcut.Copy'), 'q');
$this->assertIdentical($config->get('Shortcut.Paste'), 'p');
$this->assertIdentical($config->get('Shortcut.Cut'), 't');
}
@@ -205,7 +210,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
// generation routines have dependencies on configuration values
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
$config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$config->autoFinalize = false;
$def = $config->getCSSDefinition();
@@ -219,15 +224,15 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$old_def = clone $def2;
$config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
$config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$def = $config->getHTMLDefinition();
$this->assertIsA($def, 'HTMLPurifier_HTMLDefinition');
$this->assertNotEqual($def, $old_def);
$this->assertTrue($def->setup);
// test retrieval of raw definition
$config->set('HTML', 'DefinitionID', 'HTMLPurifier_ConfigTest->test_getHTMLDefinition()');
$config->set('HTML', 'DefinitionRev', 3);
$config->set('HTML.DefinitionID', 'HTMLPurifier_ConfigTest->test_getHTMLDefinition()');
$config->set('HTML.DefinitionRev', 3);
$def = $config->getHTMLDefinition(true);
$this->assertNotEqual($def, $old_def);
$this->assertEqual(false, $def->setup);
@@ -268,10 +273,10 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config_loadabbr = new HTMLPurifier_Config($this->schema);
$config_loadfull = new HTMLPurifier_Config($this->schema);
$config_manual->set('Zoo', 'Aadvark', 3);
$config_manual->set('Zoo', 'Boar', 5);
$config_manual->set('Zoo', 'Camel', 2000); // that's a lotta camels!
$config_manual->set('Zoo', 'Others', array('Peacock', 'Dodo')); // wtf!
$config_manual->set('Zoo.Aadvark', 3);
$config_manual->set('Zoo.Boar', 5);
$config_manual->set('Zoo.Camel', 2000); // that's a lotta camels!
$config_manual->set('Zoo.Others', array('Peacock', 'Dodo')); // wtf!
// condensed form
$config_loadabbr->loadArray(array(
@@ -302,7 +307,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$this->schema->add('Cake.Flavor', 'vanilla', 'string', false);
$config = new HTMLPurifier_Config($this->schema);
$config->set('Cake', 'Sprinkles', 42);
$config->set('Cake.Sprinkles', 42);
// test flat pass-through
$created_config = HTMLPurifier_Config::create($config, $this->schema);
@@ -326,13 +331,14 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$config = new HTMLPurifier_Config($this->schema);
$config->autoFinalize = false;
$config->chatty = false;
$config->set('Poem', 'Meter', 'irregular');
$config->set('Poem.Meter', 'irregular');
$config->finalize();
$this->expectError('Cannot set directive after finalization');
$config->set('Poem', 'Meter', 'vedic');
$config->set('Poem.Meter', 'vedic');
$this->expectError('Cannot load directives after finalization');
$config->loadArray(array('Poem.Meter' => 'octosyllable'));
@@ -422,6 +428,15 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
}
function testDeprecatedAPI() {
$this->schema->add('Foo.Bar', 2, 'int', false);
$config = new HTMLPurifier_Config($this->schema);
$config->chatty = false;
$this->expectError('Using deprecated API: use $config->set(\'Foo.Bar\', ...) instead');
$config->set('Foo', 'Bar', 4);
$this->expectError('Using deprecated API: use $config->get(\'Foo.Bar\') instead');
$this->assertIdentical($config->get('Foo', 'Bar'), 4);
}
}
// vim: et sw=4 sts=4

View File

@@ -8,7 +8,7 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial');
$config->setReturnValue('get', 2, array('Test', 'DefinitionRev'));
$config->setReturnValue('get', 2, array('Test.DefinitionRev'));
$config->version = '1.0.0';
$config_md5 = '1.0.0,serial,2';
@@ -116,12 +116,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$config1 = $this->generateConfigMock();
$config1->version = '0.9.0';
$config1->setReturnValue('get', 574, array('Test', 'DefinitionRev'));
$config1->setReturnValue('get', 574, array('Test.DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock();
$config2->version = '1.0.0beta';
$config2->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$config2->setReturnValue('get', 1, array('Test.DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1);
@@ -140,12 +140,12 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$config1 = $this->generateConfigMock('serial1');
$config1->version = '1.0.0';
$config1->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$config1->setReturnValue('get', 1, array('Test.DefinitionRev'));
$def1 = $this->generateDefinition(array('info' => 1));
$config2 = $this->generateConfigMock('serial2');
$config2->version = '1.0.0';
$config2->setReturnValue('get', 34, array('Test', 'DefinitionRev'));
$config2->setReturnValue('get', 34, array('Test.DefinitionRev'));
$def2 = $this->generateDefinition(array('info' => 3));
$cache->set($def1, $config1);
@@ -180,9 +180,9 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$cache = new HTMLPurifier_DefinitionCache_Serializer('Test');
$config = $this->generateConfigMock('serial');
$config->version = '1.0.0';
$config->setReturnValue('get', 1, array('Test', 'DefinitionRev'));
$config->setReturnValue('get', 1, array('Test.DefinitionRev'));
$dir = dirname(__FILE__) . '/SerializerTest';
$config->setReturnValue('get', $dir, array('Cache', 'SerializerPath'));
$config->setReturnValue('get', $dir, array('Cache.SerializerPath'));
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);

View File

@@ -45,21 +45,21 @@ class HTMLPurifier_DefinitionCacheFactoryTest extends HTMLPurifier_Harness
}
function test_create_invalid() {
$this->config->set('Cache', 'DefinitionImpl', 'Invalid');
$this->config->set('Cache.DefinitionImpl', 'Invalid');
$this->expectError('Unrecognized DefinitionCache Invalid, using Serializer instead');
$cache = $this->factory->create('Test', $this->config);
$this->assertIsA($cache, 'HTMLPurifier_DefinitionCache_Serializer');
}
function test_null() {
$this->config->set('Cache', 'DefinitionImpl', null);
$this->config->set('Cache.DefinitionImpl', null);
$cache = $this->factory->create('Test', $this->config);
$this->assertEqual($cache, new HTMLPurifier_DefinitionCache_Null('Test'));
}
function test_register() {
generate_mock_once('HTMLPurifier_DefinitionCache');
$this->config->set('Cache', 'DefinitionImpl', 'TestCache');
$this->config->set('Cache.DefinitionImpl', 'TestCache');
$this->factory->register('TestCache', $class = 'HTMLPurifier_DefinitionCacheMock');
$cache = $this->factory->create('Test', $this->config);
$this->assertIsA($cache, $class);

View File

@@ -10,7 +10,7 @@ class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness
generate_mock_once('HTMLPurifier_Config');
$config = new HTMLPurifier_ConfigMock();
$config->version = '1.0.0'; // hopefully no conflicts
$config->setReturnValue('get', 10, array('Test', 'DefinitionRev'));
$config->setReturnValue('get', 10, array('Test.DefinitionRev'));
$config->setReturnValue('getBatchSerial', 'hash', array('Test'));
$this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false);

View File

@@ -39,7 +39,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
}
function test_convertToUTF8_spuriousEncoding() {
$this->config->set('Core', 'Encoding', 'utf99');
$this->config->set('Core.Encoding', 'utf99');
$this->expectError('Invalid encoding utf99');
$this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
@@ -48,7 +48,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
}
function test_convertToUTF8_iso8859_1() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
"\xC3\xB6"
@@ -56,8 +56,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
}
function test_convertToUTF8_withoutIconv() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true);
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical(
HTMLPurifier_Encoder::convertToUTF8("\xF6", $this->config, $this->context),
"\xC3\xB6"
@@ -78,7 +78,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
}
function test_convertFromUTF8_iso8859_1() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
"\xF6",
@@ -88,7 +88,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_iconvNoChars() {
if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
" (Chinese)"
@@ -97,8 +97,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_phpNormal() {
// Plain PHP implementation has slightly different behavior
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true);
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8("\xC3\xB6", $this->config, $this->context),
"\xF6",
@@ -107,8 +107,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
}
function test_convertFromUTF8_phpNoChars() {
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Test', 'ForceNoIconv', true);
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Test.ForceNoIconv', true);
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
"?? (Chinese)"
@@ -117,8 +117,8 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function test_convertFromUTF8_withProtection() {
// Preserve the characters!
$this->config->set('Core', 'Encoding', 'ISO-8859-1');
$this->config->set('Core', 'EscapeNonASCIICharacters', true);
$this->config->set('Core.Encoding', 'ISO-8859-1');
$this->config->set('Core.EscapeNonASCIICharacters', true);
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8($this->getZhongWen(), $this->config, $this->context),
"&#20013;&#25991; (Chinese)"
@@ -169,7 +169,7 @@ class HTMLPurifier_EncoderTest extends HTMLPurifier_Harness
function testShiftJIS() {
if (!function_exists('iconv')) return;
$this->config->set('Core', 'Encoding', 'Shift_JIS');
$this->config->set('Core.Encoding', 'Shift_JIS');
// This actually looks like a Yen, but we're going to treat it differently
$this->assertIdentical(
HTMLPurifier_Encoder::convertFromUTF8('\\~', $this->config, $this->context),

View File

@@ -8,7 +8,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
// usual use case:
function test_tokenizeHTML_extractStyleBlocks() {
$this->config->set('Filter', 'ExtractStyleBlocks', true);
$this->config->set('Filter.ExtractStyleBlocks', true);
$purifier = new HTMLPurifier($this->config);
$result = $purifier->purify('<style type="text/css">.foo {text-align:center;bogus:remove-me;}</style>Test<style>* {font-size:12pt;}</style>');
$this->assertIdentical($result, 'Test');
@@ -23,7 +23,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
function assertExtractStyleBlocks($html, $expect = true, $styles = array()) {
$filter = new HTMLPurifier_Filter_ExtractStyleBlocks(); // disable cleaning
if ($expect === true) $expect = $html;
$this->config->set('FilterParam', 'ExtractStyleBlocksTidyImpl', false);
$this->config->set('FilterParam.ExtractStyleBlocksTidyImpl', false);
$result = $filter->preFilter($html, $this->config, $this->context);
$this->assertIdentical($result, $expect);
$this->assertIdentical($this->context->get('StyleBlocks'), $styles);
@@ -104,14 +104,14 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_noEscapeCodes() {
$this->config->set('FilterParam', 'ExtractStyleBlocksEscaping', false);
$this->config->set('FilterParam.ExtractStyleBlocksEscaping', false);
$this->assertCleanCSS(
".class {\nfont-family:'</style>';\n}"
);
}
function test_cleanCSS_scope() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(
"p {\ntext-indent:1em;\n}",
"#foo p {\ntext-indent:1em;\n}"
@@ -119,7 +119,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithSelectorCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(
"b, i {\ntext-decoration:underline;\n}",
"#foo b, #foo i {\ntext-decoration:underline;\n}"
@@ -127,17 +127,17 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithNaughtySelector() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" + p {\ntext-indent:1em;\n}", '');
}
function test_cleanCSS_scopeWithMultipleNaughtySelectors() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo');
$this->assertCleanCSS(" ++ ++ p {\ntext-indent:1em;\n}", '');
}
function test_cleanCSS_scopeWithCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS(
"p {\ntext-indent:1em;\n}",
"#foo p, .bar p {\ntext-indent:1em;\n}"
@@ -145,7 +145,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeAllWithCommas() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', '#foo, .bar');
$this->config->set('FilterParam.ExtractStyleBlocksScope', '#foo, .bar');
$this->assertCleanCSS(
"p, div {\ntext-indent:1em;\n}",
"#foo p, #foo div, .bar p, .bar div {\ntext-indent:1em;\n}"
@@ -153,7 +153,7 @@ class HTMLPurifier_Filter_ExtractStyleBlocksTest extends HTMLPurifier_Harness
}
function test_cleanCSS_scopeWithConflicts() {
$this->config->set('FilterParam', 'ExtractStyleBlocksScope', 'p');
$this->config->set('FilterParam.ExtractStyleBlocksScope', 'p');
$this->assertCleanCSS(
"div {
text-align:right;

View File

@@ -15,7 +15,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
public function setUp() {
parent::setUp();
$this->config->set('Output', 'Newline', "\n");
$this->config->set('Output.Newline', "\n");
}
/**
@@ -138,7 +138,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
function test_generateAttributes_minimized() {
$this->config->set('HTML', 'Doctype', 'HTML 4.01 Transitional');
$this->config->set('HTML.Doctype', 'HTML 4.01 Transitional');
$this->assertGenerateAttributes(
array('compact' => 'compact'), 'compact', 'menu'
);
@@ -197,7 +197,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
}
function test_generateFromTokens_Scripting_disableWrapper() {
$this->config->set('Output', 'CommentScriptContents', false);
$this->config->set('Output.CommentScriptContents', false);
$this->assertGeneration(
array(
new HTMLPurifier_Token_Start('script'),
@@ -209,7 +209,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
}
function test_generateFromTokens_XHTMLoff() {
$this->config->set('HTML', 'XHTML', false);
$this->config->set('HTML.XHTML', false);
// omit trailing slash
$this->assertGeneration(
@@ -236,8 +236,8 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
// just don't test; Tidy is exploding on me.
return;
$this->config->set('Core', 'TidyFormat', true);
$this->config->set('Output', 'Newline', "\n");
$this->config->set('Core.TidyFormat', true);
$this->config->set('Output.Newline', "\n");
// nice wrapping please
$this->assertGeneration(
@@ -252,7 +252,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_Harness
}
function test_generateFromTokens_sortAttr() {
$this->config->set('Output', 'SortAttr', true);
$this->config->set('Output.SortAttr', true);
$this->assertGeneration(
array( new HTMLPurifier_Token_Start('p', array('b'=>'c', 'a'=>'d')) ),

View File

@@ -6,7 +6,7 @@ class HTMLPurifier_HTMLDefinitionTest extends HTMLPurifier_Harness
function expectError($error = false, $message = '%s') {
// Because we're testing a definition, it's vital that the cache
// is turned off for tests that expect errors.
$this->config->set('Cache', 'DefinitionImpl', null);
$this->config->set('Cache.DefinitionImpl', null);
parent::expectError($error);
}
@@ -87,29 +87,29 @@ a[href|title]
}
function test_AllowedElements() {
$this->config->set('HTML', 'AllowedElements', 'p');
$this->config->set('HTML.AllowedElements', 'p');
$this->assertPurification_AllowedElements_p();
}
function test_AllowedElements_multiple() {
$this->config->set('HTML', 'AllowedElements', 'p,div');
$this->config->set('HTML.AllowedElements', 'p,div');
$this->assertPurification('<div><p><b>Jelly</b></p></div>', '<div><p>Jelly</p></div>');
}
function test_AllowedElements_invalidElement() {
$this->config->set('HTML', 'AllowedElements', 'obviously_invalid,p');
$this->config->set('HTML.AllowedElements', 'obviously_invalid,p');
$this->expectError(new PatternExpectation("/Element 'obviously_invalid' is not supported/"));
$this->assertPurification_AllowedElements_p();
}
function test_AllowedElements_invalidElement_xssAttempt() {
$this->config->set('HTML', 'AllowedElements', '<script>,p');
$this->config->set('HTML.AllowedElements', '<script>,p');
$this->expectError(new PatternExpectation("/Element '&lt;script&gt;' is not supported/"));
$this->assertPurification_AllowedElements_p();
}
function test_AllowedElements_multipleInvalidElements() {
$this->config->set('HTML', 'AllowedElements', 'dr-wiggles,dr-pepper,p');
$this->config->set('HTML.AllowedElements', 'dr-wiggles,dr-pepper,p');
$this->expectError(new PatternExpectation("/Element 'dr-wiggles' is not supported/"));
$this->expectError(new PatternExpectation("/Element 'dr-pepper' is not supported/"));
$this->assertPurification_AllowedElements_p();
@@ -122,18 +122,18 @@ a[href|title]
}
function test_AllowedAttributes_global_preferredSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'style');
$this->config->set('HTML.AllowedAttributes', 'style');
$this->assertPurification_AllowedAttributes_global_style();
}
function test_AllowedAttributes_global_verboseSyntax() {
$this->config->set('HTML', 'AllowedAttributes', '*@style');
$this->config->set('HTML.AllowedAttributes', '*@style');
$this->assertPurification_AllowedAttributes_global_style();
}
function test_AllowedAttributes_global_discouragedSyntax() {
// Emit errors eventually
$this->config->set('HTML', 'AllowedAttributes', '*.style');
$this->config->set('HTML.AllowedAttributes', '*.style');
$this->assertPurification_AllowedAttributes_global_style();
}
@@ -144,17 +144,17 @@ a[href|title]
}
function test_AllowedAttributes_local_preferredSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'p@style');
$this->config->set('HTML.AllowedAttributes', 'p@style');
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_AllowedAttributes_local_discouragedSyntax() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style');
$this->config->set('HTML.AllowedAttributes', 'p.style');
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_AllowedAttributes_multiple() {
$this->config->set('HTML', 'AllowedAttributes', 'p@style,br@class,title');
$this->config->set('HTML.AllowedAttributes', 'p@style,br@class,title');
$this->assertPurification(
'<p style="font-weight:bold;" class="foo" title="foo">Jelly</p><br style="clear:both;" class="foo" title="foo" />',
'<p style="font-weight:bold;" title="foo">Jelly</p><br class="foo" title="foo" />'
@@ -162,42 +162,42 @@ a[href|title]
}
function test_AllowedAttributes_local_invalidAttribute() {
$this->config->set('HTML', 'AllowedAttributes', array('p@style', 'p@<foo>'));
$this->config->set('HTML.AllowedAttributes', array('p@style', 'p@<foo>'));
$this->expectError(new PatternExpectation("/Attribute '&lt;foo&gt;' in element 'p' not supported/"));
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_AllowedAttributes_global_invalidAttribute() {
$this->config->set('HTML', 'AllowedAttributes', array('style', '<foo>'));
$this->config->set('HTML.AllowedAttributes', array('style', '<foo>'));
$this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/"));
$this->assertPurification_AllowedAttributes_global_style();
}
function test_AllowedAttributes_local_invalidAttributeDueToMissingElement() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,foo.style');
$this->config->set('HTML.AllowedAttributes', 'p.style,foo.style');
$this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/"));
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_AllowedAttributes_duplicate() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,p@style');
$this->config->set('HTML.AllowedAttributes', 'p.style,p@style');
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_AllowedAttributes_multipleErrors() {
$this->config->set('HTML', 'AllowedAttributes', 'p.style,foo.style,<foo>');
$this->config->set('HTML.AllowedAttributes', 'p.style,foo.style,<foo>');
$this->expectError(new PatternExpectation("/Cannot allow attribute 'style' if element 'foo' is not allowed\/supported/"));
$this->expectError(new PatternExpectation("/Global attribute '&lt;foo&gt;' is not supported in any elements/"));
$this->assertPurification_AllowedAttributes_local_p_style();
}
function test_ForbiddenElements() {
$this->config->set('HTML', 'ForbiddenElements', 'b');
$this->config->set('HTML.ForbiddenElements', 'b');
$this->assertPurification('<b>b</b><i>i</i>', 'b<i>i</i>');
}
function test_ForbiddenElements_invalidElement() {
$this->config->set('HTML', 'ForbiddenElements', 'obviously_incorrect');
$this->config->set('HTML.ForbiddenElements', 'obviously_incorrect');
// no error!
$this->assertPurification('<i>i</i>');
}
@@ -209,18 +209,18 @@ a[href|title]
}
function test_ForbiddenAttributes() {
$this->config->set('HTML', 'ForbiddenAttributes', 'b@style');
$this->config->set('HTML.ForbiddenAttributes', 'b@style');
$this->assertPurification_ForbiddenAttributes_b_style();
}
function test_ForbiddenAttributes_incorrectSyntax() {
$this->config->set('HTML', 'ForbiddenAttributes', 'b.style');
$this->config->set('HTML.ForbiddenAttributes', 'b.style');
$this->expectError("Error with b.style: tag.attr syntax not supported for HTML.ForbiddenAttributes; use tag@attr instead");
$this->assertPurification('<b style="float:left;">Test</b>');
}
function test_ForbiddenAttributes_incorrectGlobalSyntax() {
$this->config->set('HTML', 'ForbiddenAttributes', '*.style');
$this->config->set('HTML.ForbiddenAttributes', '*.style');
$this->expectError("Error with *.style: *.attr syntax not supported for HTML.ForbiddenAttributes; use attr instead");
$this->assertPurification('<b style="float:left;">Test</b>');
}
@@ -232,12 +232,12 @@ a[href|title]
}
function test_ForbiddenAttributes_global() {
$this->config->set('HTML', 'ForbiddenAttributes', 'style');
$this->config->set('HTML.ForbiddenAttributes', 'style');
$this->assertPurification_ForbiddenAttributes_style();
}
function test_ForbiddenAttributes_globalVerboseFormat() {
$this->config->set('HTML', 'ForbiddenAttributes', '*@style');
$this->config->set('HTML.ForbiddenAttributes', '*@style');
$this->assertPurification_ForbiddenAttributes_style();
}
@@ -288,7 +288,7 @@ a[href|title]
}
function test_injector() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injector');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injector');
generate_mock_once('HTMLPurifier_Injector');
$injector = new HTMLPurifier_InjectorMock();
@@ -306,7 +306,7 @@ a[href|title]
}
function test_injectorMissingNeeded() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorMissingNeeded');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorMissingNeeded');
generate_mock_once('HTMLPurifier_Injector');
$injector = new HTMLPurifier_InjectorMock();
@@ -322,7 +322,7 @@ a[href|title]
}
function test_injectorIntegration() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegration');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegration');
$module = $this->config->getHTMLDefinition(true)->getAnonymousModule();
$module->info_injector[] = 'Linkify';
@@ -334,9 +334,9 @@ a[href|title]
}
function test_injectorIntegrationFail() {
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegrationFail');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLDefinitionTest->test_injectorIntegrationFail');
$this->config->set('HTML', 'Allowed', 'p');
$this->config->set('HTML.Allowed', 'p');
$module = $this->config->getHTMLDefinition(true)->getAnonymousModule();
$module->info_injector[] = 'Linkify';

View File

@@ -5,9 +5,9 @@ class HTMLPurifier_HTMLModule_FormsTest extends HTMLPurifier_HTMLModuleHarness
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Cache', 'DefinitionImpl', null);
$this->config->set('HTML.Trusted', true);
$this->config->set('Attr.EnableID', true);
$this->config->set('Cache.DefinitionImpl', null);
}
function testBasicUse() {

View File

@@ -23,7 +23,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
}
function testLengthCustomMax() {
$this->config->set('HTML', 'MaxImgLength', 20);
$this->config->set('HTML.MaxImgLength', 20);
$this->assertResult(
'<img height="30" width="30" src="" alt="" />',
'<img height="20" width="20" src="" alt="" />'
@@ -31,7 +31,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
}
function testLengthCrashFixDisabled() {
$this->config->set('HTML', 'MaxImgLength', null);
$this->config->set('HTML.MaxImgLength', null);
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />'
);
@@ -41,7 +41,7 @@ class HTMLPurifier_HTMLModule_ImageTest extends HTMLPurifier_HTMLModuleHarness
}
function testLengthTrusted() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->assertResult(
'<img height="100%" width="100%" src="" alt="" />'
);

View File

@@ -5,11 +5,11 @@ class HTMLPurifier_HTMLModule_ObjectTest extends HTMLPurifier_HTMLModuleHarness
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
}
function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false);
$this->config->set('HTML.Trusted', false);
$this->assertResult(
'<object></object>', ''
);

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_ProprietaryTest extends HTMLPurifier_HTMLModuleHar
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Proprietary', true);
$this->config->set('HTML.Proprietary', true);
}
function testMarquee() {

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_RubyTest extends HTMLPurifier_HTMLModuleHarness
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Doctype', 'XHTML 1.1');
$this->config->set('HTML.Doctype', 'XHTML 1.1');
}
function testBasicUse() {

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_SafeEmbedTest extends HTMLPurifier_HTMLModuleHarne
function setUp() {
parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeEmbedTest');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeEmbedTest');
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeEmbed');
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_HTMLModule_SafeObjectTest extends HTMLPurifier_HTMLModuleHarn
function setUp() {
parent::setUp();
$this->config->set('HTML', 'DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$this->config->set('HTML.DefinitionID', 'HTMLPurifier_HTMLModule_SafeObjectTest');
$def = $this->config->getHTMLDefinition(true);
$def->manager->addModule('SafeObject');
}

View File

@@ -5,12 +5,12 @@ class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarne
function setUp() {
parent::setUp();
$this->config->set('HTML', 'Trusted', true);
$this->config->set('Output', 'CommentScriptContents', false);
$this->config->set('HTML.Trusted', true);
$this->config->set('Output.CommentScriptContents', false);
}
function testDefaultRemoval() {
$this->config->set('HTML', 'Trusted', false);
$this->config->set('HTML.Trusted', false);
$this->assertResult(
'<script type="text/javascript">foo();</script>', ''
);

View File

@@ -6,7 +6,7 @@ class HTMLPurifier_HTMLModuleManagerTest extends HTMLPurifier_Harness
protected function createManager() {
$manager = new HTMLPurifier_HTMLModuleManager();
$this->config->set('HTML', 'CustomDoctype', 'Blank');
$this->config->set('HTML.CustomDoctype', 'Blank');
$manager->doctypes->register('Blank');
$attrdef_nmtokens = new HTMLPurifier_AttrDef_HTML_Nmtokens();
@@ -47,8 +47,8 @@ class HTMLPurifier_HTMLModuleManagerTest extends HTMLPurifier_Harness
$manager->addModule($unsafe_module);
$config = HTMLPurifier_Config::createDefault();
$config->set('HTML', 'Trusted', false);
$config->set('HTML', 'CustomDoctype', 'Blank');
$config->set('HTML.Trusted', false);
$config->set('HTML.CustomDoctype', 'Blank');
$manager->setup($config);

View File

@@ -15,7 +15,7 @@ class HTMLPurifier_HTMLT extends HTMLPurifier_Harness
if (isset($hash['SKIPIF'])) {
if (eval($hash['SKIPIF'])) return;
}
$this->config->set('Output', 'Newline', "\n");
$this->config->set('Output.Newline', "\n");
if (isset($hash['INI'])) {
// there should be a more efficient way than writing another
// ini file every time... probably means building a parser for

View File

@@ -18,7 +18,7 @@ class HTMLPurifier_Harness extends UnitTestCase
*/
public function setUp() {
list($this->config, $this->context) = $this->createCommon();
$this->config->set('Output', 'Newline', '
$this->config->set('Output.Newline', '
');
$this->purifier = new HTMLPurifier();
}

View File

@@ -29,7 +29,7 @@ class HTMLPurifier_IDAccumulatorTest extends HTMLPurifier_Harness
}
function testBuild() {
$this->config->set('Attr', 'IDBlacklist', array('foo'));
$this->config->set('Attr.IDBlacklist', array('foo'));
$accumulator = HTMLPurifier_IDAccumulator::build($this->config, $this->context);
$this->assertTrue( isset($accumulator->ids['foo']) );
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Injector_AutoParagraphTest extends HTMLPurifier_InjectorHarne
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'AutoParagraph', true);
$this->config->set('AutoFormat.AutoParagraph', true);
}
function testSingleParagraph() {
@@ -385,7 +385,7 @@ Par1
}
function testNoParagraphWithInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span');
$this->config->set('HTML.Parent', 'span');
$this->assertResult(
'Par
@@ -498,7 +498,7 @@ Bar</div>",
}
function testErrorNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->assertResult('<b>foobar</b>');
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Injector_DisplayLinkURITest extends HTMLPurifier_InjectorHarn
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'DisplayLinkURI', true);
$this->config->set('AutoFormat.DisplayLinkURI', true);
}
function testBasicLink() {

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'Linkify', true);
$this->config->set('AutoFormat.Linkify', true);
}
function testLinkifyURLInRootNode() {
@@ -36,7 +36,7 @@ class HTMLPurifier_Injector_LinkifyTest extends HTMLPurifier_InjectorHarness
}
function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('http://example.com/');
}

View File

@@ -5,8 +5,8 @@ class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHar
function setup() {
parent::setup();
$this->config->set('AutoFormat', 'PurifierLinkify', true);
$this->config->set('AutoFormatParam', 'PurifierLinkifyDocURL', '#%s');
$this->config->set('AutoFormat.PurifierLinkify', true);
$this->config->set('AutoFormatParam.PurifierLinkifyDocURL', '#%s');
}
function testNoTriggerCharacer() {
@@ -49,7 +49,7 @@ class HTMLPurifier_Injector_PurifierLinkifyTest extends HTMLPurifier_InjectorHar
}
function testNeeded() {
$this->config->set('HTML', 'Allowed', 'b');
$this->config->set('HTML.Allowed', 'b');
$this->expectError('Cannot enable PurifierLinkify injector because a is not allowed');
$this->assertResult('%Namespace.Directive');
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
public function setup() {
parent::setup();
$this->config->set('AutoFormat', 'RemoveEmpty', true);
$this->config->set('AutoFormat.RemoveEmpty', true);
}
function testPreserve() {
@@ -33,12 +33,12 @@ class HTMLPurifier_Injector_RemoveEmptyTest extends HTMLPurifier_InjectorHarness
}
function testPreserveId() {
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Attr.EnableID', true);
$this->assertResult('<a id="asdf"></a>');
}
function testPreserveName() {
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Attr.EnableID', true);
$this->assertResult('<a name="asdf"></a>');
}

View File

@@ -11,8 +11,8 @@ 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);
$this->config->set('AutoFormat.Custom', array(new HTMLPurifier_Injector_SafeObject()));
$this->config->set('HTML.Trusted', true);
}
function testPreserve() {

View File

@@ -15,7 +15,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
function test() {
$this->config->set('Core', 'Language', 'en');
$this->config->set('Core.Language', 'en');
$language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language');
@@ -30,7 +30,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
function testFallback() {
$this->config->set('Core', 'Language', 'en-x-test');
$this->config->set('Core.Language', 'en-x-test');
$language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language_en_x_test');
@@ -47,7 +47,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
}
function testFallbackWithNoClass() {
$this->config->set('Core', 'Language', 'en-x-testmini');
$this->config->set('Core.Language', 'en-x-testmini');
$language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertIdentical($language->code, 'en-x-testmini');
@@ -58,7 +58,7 @@ class HTMLPurifier_LanguageFactoryTest extends HTMLPurifier_Harness
}
function testNoSuchLanguage() {
$this->config->set('Core', 'Language', 'en-x-testnone');
$this->config->set('Core.Language', 'en-x-testnone');
$language = $this->factory->create($this->config, $this->context);
$this->assertIsA($language, 'HTMLPurifier_Language');
$this->assertIdentical($language->code, 'en-x-testnone');

View File

@@ -24,26 +24,26 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
// HTMLPurifier_Lexer::create() --------------------------------------------
function test_create() {
$this->config->set('Core', 'MaintainLineNumbers', true);
$this->config->set('Core.MaintainLineNumbers', true);
$lexer = HTMLPurifier_Lexer::create($this->config);
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
}
function test_create_objectLexerImpl() {
$this->config->set('Core', 'LexerImpl', new HTMLPurifier_Lexer_DirectLex());
$this->config->set('Core.LexerImpl', new HTMLPurifier_Lexer_DirectLex());
$lexer = HTMLPurifier_Lexer::create($this->config);
$this->assertIsA($lexer, 'HTMLPurifier_Lexer_DirectLex');
}
function test_create_unknownLexer() {
$this->config->set('Core', 'LexerImpl', 'AsdfAsdf');
$this->config->set('Core.LexerImpl', 'AsdfAsdf');
$this->expectException(new HTMLPurifier_Exception('Cannot instantiate unrecognized Lexer type AsdfAsdf'));
HTMLPurifier_Lexer::create($this->config);
}
function test_create_incompatibleLexer() {
$this->config->set('Core', 'LexerImpl', 'DOMLex');
$this->config->set('Core', 'MaintainLineNumbers', true);
$this->config->set('Core.LexerImpl', 'DOMLex');
$this->config->set('Core.MaintainLineNumbers', true);
$this->expectException(new HTMLPurifier_Exception('Cannot use lexer that does not support line numbers with Core.MaintainLineNumbers or Core.CollectErrors (use DirectLex instead)'));
HTMLPurifier_Lexer::create($this->config);
}
@@ -491,7 +491,7 @@ class HTMLPurifier_LexerTest extends HTMLPurifier_Harness
}
function test_tokenizeHTML_scriptCDATAContents() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->assertTokenization(
'Foo: <script>alert("<foo>");</script>',
array(

View File

@@ -24,7 +24,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
}
function testEscapeBlockInInline() {
$this->config->set('Core', 'EscapeInvalidChildren', true);
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult(
'<b><div>Illegal div.</div></b>',
'<b>&lt;div&gt;Illegal div.&lt;/div&gt;</b>'
@@ -78,7 +78,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
}
function testChameleonEscapeInvalidBlockInInline() {
$this->config->set('Core', 'EscapeInvalidChildren', true);
$this->config->set('Core.EscapeInvalidChildren', true);
$this->assertResult( // alt config
'<span><ins><div>Not allowed!</div></ins></span>',
'<span><ins>&lt;div&gt;Not allowed!&lt;/div&gt;</ins></span>'
@@ -94,19 +94,19 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
}
function testPreserveInlineNodeInInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span');
$this->config->set('HTML.Parent', 'span');
$this->assertResult('<b>Bold</b>');
}
function testRemoveBlockNodeInInlineRootNode() {
$this->config->set('HTML', 'Parent', 'span');
$this->config->set('HTML.Parent', 'span');
$this->assertResult('<div>Reject</div>', 'Reject');
}
function testInvalidParentError() {
// test fallback to div
$this->config->set('HTML', 'Parent', 'obviously-impossible');
$this->config->set('Cache', 'DefinitionImpl', null);
$this->config->set('HTML.Parent', 'obviously-impossible');
$this->config->set('Cache.DefinitionImpl', null);
$this->expectError('Cannot use unrecognized element as parent');
$this->assertResult('<div>Accept</div>');
}
@@ -128,7 +128,7 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness
}
function testStrictBlockquoteInHTML401() {
$this->config->set('HTML', 'Doctype', 'HTML 4.01 Strict');
$this->config->set('HTML.Doctype', 'HTML 4.01 Strict');
$this->assertResult('<blockquote>text</blockquote>', '<blockquote><p>text</p></blockquote>');
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjectorTest extends HTMLPur
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array(
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndInsertInjector()
));
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjectorTest extends HTMLPur
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array(
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector()
));
}
@@ -22,7 +22,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjectorTest extends HTMLPur
$this->assertResult('<b></b><span>asdf</span><b></b>','<b></b><b></b>');
}
function testDoubled() {
$this->config->set('AutoFormat', 'Custom', array(
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_EndRewindInjector(),
));

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_SkipInjectorTest extends HTMLPurifier
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'Custom', array(
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()
));
}
@@ -16,7 +16,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_SkipInjectorTest extends HTMLPurifier
$this->assertResult('<br />', '<br /><br />');
}
function testMultiplyMultiply() {
$this->config->set('AutoFormat', 'Custom', array(
$this->config->set('AutoFormat.Custom', array(
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector(),
new HTMLPurifier_Strategy_MakeWellFormed_SkipInjector()
));

View File

@@ -94,7 +94,7 @@ class HTMLPurifier_Strategy_MakeWellFormedTest extends HTMLPurifier_StrategyHarn
}
function testBlockquoteWithInline() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->assertResult(
// This is actually invalid, but will be fixed by
// ChildDef_StrictBlockquote

View File

@@ -14,7 +14,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strat
}
function testUnnecessaryEndTagToText() {
$this->config->set('Core', 'EscapeInvalidTags', true);
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Unnecessary end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 0));
$this->invoke('</b>');
@@ -40,7 +40,7 @@ class HTMLPurifier_Strategy_MakeWellFormed_ErrorsTest extends HTMLPurifier_Strat
}
function testStrayEndTagToText() {
$this->config->set('Core', 'EscapeInvalidTags', true);
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_MakeWellFormed: Stray end tag to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_End('b', array(), 1, 3));
$this->invoke('<i></b></i>');

View File

@@ -6,9 +6,9 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_MakeWellFormed();
$this->config->set('AutoFormat', 'AutoParagraph', true);
$this->config->set('AutoFormat', 'Linkify', true);
$this->config->set('AutoFormat', 'RemoveEmpty', true);
$this->config->set('AutoFormat.AutoParagraph', true);
$this->config->set('AutoFormat.Linkify', true);
$this->config->set('AutoFormat.RemoveEmpty', true);
generate_mock_once('HTMLPurifier_Injector');
}
@@ -26,21 +26,21 @@ class HTMLPurifier_Strategy_MakeWellFormed_InjectorTest extends HTMLPurifier_Str
$mock->expectAt(1, 'handleEnd', array($i));
$mock->expectCallCount('handleEnd', 2);
$mock->setReturnValue('getRewind', false);
$this->config->set('AutoFormat', 'AutoParagraph', false);
$this->config->set('AutoFormat', 'Linkify', false);
$this->config->set('AutoFormat', 'Custom', array($mock));
$this->config->set('AutoFormat.AutoParagraph', false);
$this->config->set('AutoFormat.Linkify', false);
$this->config->set('AutoFormat.Custom', array($mock));
$this->assertResult('<i><b>asdf</b>', '<i><b>asdf</b></i>');
}
function testErrorRequiredElementNotAllowed() {
$this->config->set('HTML', 'Allowed', '');
$this->config->set('HTML.Allowed', '');
$this->expectError('Cannot enable AutoParagraph injector because p is not allowed');
$this->expectError('Cannot enable Linkify injector because a is not allowed');
$this->assertResult('Foobar');
}
function testErrorRequiredAttributeNotAllowed() {
$this->config->set('HTML', 'Allowed', 'a,p');
$this->config->set('HTML.Allowed', 'a,p');
$this->expectError('Cannot enable Linkify injector because a.href is not allowed');
$this->assertResult('<p>http://example.com</p>');
}

View File

@@ -38,7 +38,7 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
}
function testRemoveOnlyScriptTagsLegacy() {
$this->config->set('Core', 'RemoveScriptContents', false);
$this->config->set('Core.RemoveScriptContents', false);
$this->assertResult(
'<script>alert();</script>',
'alert();'
@@ -46,7 +46,7 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
}
function testRemoveOnlyScriptTags() {
$this->config->set('Core', 'HiddenElements', array());
$this->config->set('Core.HiddenElements', array());
$this->assertResult(
'<script>alert();</script>',
'alert();'
@@ -62,13 +62,13 @@ class HTMLPurifier_Strategy_RemoveForeignElementsTest extends HTMLPurifier_Strat
}
function testPreserveInvalidImgWhenRemovalIsDisabled() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult('<img />');
}
function testTextifyCommentedScriptContents() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('Output', 'CommentScriptContents', false); // simplify output
$this->config->set('HTML.Trusted', true);
$this->config->set('Output.CommentScriptContents', false); // simplify output
$this->assertResult(
'<script type="text/javascript"><!--
alert(<b>bold</b>);
@@ -80,7 +80,7 @@ alert(&lt;b&gt;bold&lt;/b&gt;);
}
function testRequiredAttributesTestNotPerformedOnEndTag() {
$this->config->set('HTML', 'DefinitionID',
$this->config->set('HTML.DefinitionID',
'HTMLPurifier_Strategy_RemoveForeignElementsTest'.
'->testRequiredAttributesTestNotPerformedOnEndTag');
$def = $this->config->getHTMLDefinition(true);
@@ -89,17 +89,17 @@ alert(&lt;b&gt;bold&lt;/b&gt;);
}
function testPreserveCommentsWithHTMLTrusted() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo -->');
}
function testRemoveTrailingHyphensInComment() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- foo ----->', '<!-- foo -->');
}
function testCollapseDoubleHyphensInComment() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->assertResult('<!-- bo --- asdf--as -->', '<!-- bo - asdf-as -->');
}

View File

@@ -5,7 +5,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
public function setup() {
parent::setup();
$this->config->set('HTML', 'TidyLevel', 'heavy');
$this->config->set('HTML.TidyLevel', 'heavy');
}
protected function getStrategy() {
@@ -26,7 +26,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
}
function testForeignElementToText() {
$this->config->set('Core', 'EscapeInvalidTags', true);
$this->config->set('Core.EscapeInvalidTags', true);
$this->expectErrorCollection(E_WARNING, 'Strategy_RemoveForeignElements: Foreign element to text');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Start('invalid', array(), 1));
$this->invoke('<invalid>');
@@ -46,14 +46,14 @@ class HTMLPurifier_Strategy_RemoveForeignElements_ErrorsTest extends HTMLPurifie
}
function testTrailingHyphenInCommentRemoved() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Trailing hyphen in comment removed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --', 1));
$this->invoke('<!-- test ---->');
}
function testDoubleHyphenInCommentRemoved() {
$this->config->set('HTML', 'Trusted', true);
$this->config->set('HTML.Trusted', true);
$this->expectErrorCollection(E_NOTICE, 'Strategy_RemoveForeignElements: Hyphens in comment collapsed');
$this->expectContext('CurrentToken', new HTMLPurifier_Token_Comment(' test --- test -- test ', 1));
$this->invoke('<!-- test --- test -- test -->');

View File

@@ -7,7 +7,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_RemoveForeignElements();
$this->config->set('HTML', 'TidyLevel', 'heavy');
$this->config->set('HTML.TidyLevel', 'heavy');
}
function testCenterTransform() {
@@ -26,7 +26,7 @@ class HTMLPurifier_Strategy_RemoveForeignElements_TidyTest
}
function testTransformToForbiddenElement() {
$this->config->set('HTML', 'Allowed', 'div');
$this->config->set('HTML.Allowed', 'div');
$this->assertResult(
'<font color="red" face="Arial" size="6">Big Warning!</font>',
'Big Warning!'

View File

@@ -52,7 +52,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testOnlyXMLLangInXHTML11() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.1');
$this->config->set('HTML.Doctype', 'XHTML 1.1');
$this->assertResult(
'<b lang="en">asdf</b>',
'<b xml:lang="en">asdf</b>'
@@ -85,7 +85,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testBdoAlternateDefaultDir() {
$this->config->set('Attr', 'DefaultTextDir', 'rtl');
$this->config->set('Attr.DefaultTextDir', 'rtl');
$this->assertResult(
'<bdo>Go right.</bdo>',
'<bdo dir="rtl">Go right.</bdo>'
@@ -127,7 +127,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testImgAddDefaults() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img />',
'<img src="" alt="Invalid image" />'
@@ -142,7 +142,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testImgAddDefaultSrc() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img alt="pretty picture" />',
'<img alt="pretty picture" src="" />'
@@ -150,7 +150,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testImgRemoveNonRetrievableProtocol() {
$this->config->set('Core', 'RemoveInvalidImg', false);
$this->config->set('Core.RemoveInvalidImg', false);
$this->assertResult(
'<img src="mailto:foo@example.com" />',
'<img alt="mailto:foo@example.com" src="" />'
@@ -158,19 +158,19 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testPreserveRel() {
$this->config->set('Attr', 'AllowedRel', 'nofollow');
$this->config->set('Attr.AllowedRel', 'nofollow');
$this->assertResult('<a href="foo" rel="nofollow" />');
}
function testPreserveTarget() {
$this->config->set('Attr', 'AllowedFrameTargets', '_top');
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Transitional');
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->config->set('HTML.Doctype', 'XHTML 1.0 Transitional');
$this->assertResult('<a href="foo" target="_top" />');
}
function testRemoveTargetWhenNotSupported() {
$this->config->set('HTML', 'Doctype', 'XHTML 1.0 Strict');
$this->config->set('Attr', 'AllowedFrameTargets', '_top');
$this->config->set('HTML.Doctype', 'XHTML 1.0 Strict');
$this->config->set('Attr.AllowedFrameTargets', '_top');
$this->assertResult(
'<a href="foo" target="_top" />',
'<a href="foo" />'
@@ -191,7 +191,7 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testRemoveLargeCSSWidthAndHeightOnImgWithUserConf() {
$this->config->set('CSS', 'MaxImgLength', '1px');
$this->config->set('CSS.MaxImgLength', '1px');
$this->assertResult(
'<img src="" alt="" style="width:1mm;height:1mm;border:1px solid #000;" />',
'<img src="" alt="" style="border:1px solid #000;" />'
@@ -199,14 +199,14 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends
}
function testKeepLargeCSSWidthAndHeightOnImgWhenToldTo() {
$this->config->set('CSS', 'MaxImgLength', null);
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:10000000px;height:10000000px;border:1px solid #000;" />'
);
}
function testKeepPercentCSSWidthAndHeightOnImgWhenToldTo() {
$this->config->set('CSS', 'MaxImgLength', null);
$this->config->set('CSS.MaxImgLength', null);
$this->assertResult(
'<img src="" alt="" style="width:100%;height:100%;border:1px solid #000;" />'
);

View File

@@ -6,7 +6,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('Attr', 'EnableID', true);
$this->config->set('Attr.EnableID', true);
}
@@ -43,7 +43,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
}
function testIDBlacklist() {
$this->config->set('Attr', 'IDBlacklist', array('invalid'));
$this->config->set('Attr.IDBlacklist', array('invalid'));
$this->assertResult(
'<div id="invalid">Invalid</div>',
'<div>Invalid</div>'
@@ -51,7 +51,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
}
function testNameConvertedToID() {
$this->config->set('HTML', 'TidyLevel', 'heavy');
$this->config->set('HTML.TidyLevel', 'heavy');
$this->assertResult(
'<a name="foobar" />',
'<a id="foobar" />'

View File

@@ -6,7 +6,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_TidyTest extends HTMLPurifier_Str
function setUp() {
parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('HTML', 'TidyLevel', 'heavy');
$this->config->set('HTML.TidyLevel', 'heavy');
}
function testConvertCenterAlign() {

View File

@@ -33,9 +33,9 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
}
function test_setupMemberVariables_collisionPrecedenceIsHostBaseScheme() {
$this->config->set('URI', 'Host', $host = 'example.com');
$this->config->set('URI', 'Base', $base = 'http://sub.example.com/foo/bar.html');
$this->config->set('URI', 'DefaultScheme', 'ftp');
$this->config->set('URI.Host', $host = 'example.com');
$this->config->set('URI.Base', $base = 'http://sub.example.com/foo/bar.html');
$this->config->set('URI.DefaultScheme', 'ftp');
$def = new HTMLPurifier_URIDefinition();
$def->setup($this->config);
$this->assertIdentical($def->host, $host);
@@ -44,14 +44,14 @@ class HTMLPurifier_URIDefinitionTest extends HTMLPurifier_URIHarness
}
function test_setupMemberVariables_onlyScheme() {
$this->config->set('URI', 'DefaultScheme', 'ftp');
$this->config->set('URI.DefaultScheme', 'ftp');
$def = new HTMLPurifier_URIDefinition();
$def->setup($this->config);
$this->assertIdentical($def->defaultScheme, 'ftp');
}
function test_setupMemberVariables_onlyBase() {
$this->config->set('URI', 'Base', 'http://sub.example.com/foo/bar.html');
$this->config->set('URI.Base', 'http://sub.example.com/foo/bar.html');
$def = new HTMLPurifier_URIDefinition();
$def->setup($this->config);
$this->assertIdentical($def->host, 'sub.example.com');

View File

@@ -21,28 +21,28 @@ class HTMLPurifier_URIFilter_DisableExternalTest extends HTMLPurifier_URIFilterH
}
function testPreserveOurHost() {
$this->config->set('URI', 'Host', 'example.com');
$this->config->set('URI.Host', 'example.com');
$this->assertFiltering(
'http://example.com'
);
}
function testPreserveOurSubdomain() {
$this->config->set('URI', 'Host', 'example.com');
$this->config->set('URI.Host', 'example.com');
$this->assertFiltering(
'http://www.example.com'
);
}
function testRemoveSuperdomain() {
$this->config->set('URI', 'Host', 'www.example.com');
$this->config->set('URI.Host', 'www.example.com');
$this->assertFiltering(
'http://example.com', false
);
}
function testBaseAsHost() {
$this->config->set('URI', 'Base', 'http://www.example.com/foo/bar');
$this->config->set('URI.Base', 'http://www.example.com/foo/bar');
$this->assertFiltering(
'http://www.example.com/baz'
);

View File

@@ -9,18 +9,18 @@ class HTMLPurifier_URIFilter_HostBlacklistTest extends HTMLPurifier_URIFilterHar
}
function testRejectBlacklistedHost() {
$this->config->set('URI', 'HostBlacklist', 'example.com');
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://example.com', false);
}
function testRejectBlacklistedHostThoughNotTrue() {
// maybe this behavior should change
$this->config->set('URI', 'HostBlacklist', 'example.com');
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://example.comcast.com', false);
}
function testPreserveNonBlacklistedHost() {
$this->config->set('URI', 'HostBlacklist', 'example.com');
$this->config->set('URI.HostBlacklist', 'example.com');
$this->assertFiltering('http://google.com');
}

View File

@@ -10,7 +10,7 @@ class HTMLPurifier_URIFilter_MakeAbsoluteTest extends HTMLPurifier_URIFilterHarn
}
function setBase($base = 'http://example.com/foo/bar.html?q=s#frag') {
$this->config->set('URI', 'Base', $base);
$this->config->set('URI.Base', $base);
}
// corresponding to RFC 2396

View File

@@ -9,12 +9,12 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
}
protected function setMunge($uri = 'http://www.google.com/url?q=%s') {
$this->config->set('URI', 'Munge', $uri);
$this->config->set('URI.Munge', $uri);
}
protected function setSecureMunge($key = 'secret') {
$this->setMunge('/redirect.php?url=%s&checksum=%t');
$this->config->set('URI', 'MungeSecretKey', $key);
$this->config->set('URI.MungeSecretKey', $key);
}
function testMunge() {
@@ -62,7 +62,7 @@ class HTMLPurifier_URIFilter_MungeTest extends HTMLPurifier_URIFilterHarness
function testProcessEmbedded() {
$this->setMunge();
$this->config->set('URI', 'MungeResources', true);
$this->config->set('URI.MungeResources', true);
$embeds = true;
$this->context->register('EmbeddedURI', $embeds);
$this->assertFiltering('http://www.example.com/', 'http://www.google.com/url?q=http%3A%2F%2Fwww.example.com%2F');

View File

@@ -66,7 +66,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
$scheme = 'foobar';
$scheme_mock = $this->setUpSchemeMock($scheme);
$this->config->set('URI', 'DefaultScheme', $scheme);
$this->config->set('URI.DefaultScheme', $scheme);
$uri = $this->createURI('hmm');
$scheme_obj = $uri->getSchemeObj($this->config, $this->context);
@@ -77,7 +77,7 @@ class HTMLPurifier_URITest extends HTMLPurifier_URIHarness
function test_getSchemaObj_invalidDefaultScheme() {
$this->setUpNoValidSchemes();
$this->config->set('URI', 'DefaultScheme', 'foobar');
$this->config->set('URI.DefaultScheme', 'foobar');
$uri = $this->createURI('hmm');

View File

@@ -28,8 +28,8 @@ class HTMLPurifierTest extends HTMLPurifier_Harness
}
function testMakeAbsolute() {
$this->config->set('URI', 'Base', 'http://example.com/bar/baz.php');
$this->config->set('URI', 'MakeAbsolute', true);
$this->config->set('URI.Base', 'http://example.com/bar/baz.php');
$this->config->set('URI.MakeAbsolute', true);
$this->assertPurification(
'<a href="foo.txt">Foobar</a>',
'<a href="http://example.com/bar/foo.txt">Foobar</a>'