0
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2024-11-09 15:28:40 +00:00

[3.1.0] Emit notice if setting configuration alias, and fix up our test code not to use aliases

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1643 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang 2008-04-03 21:53:06 +00:00
parent 870a4029ec
commit dac98cdb06
8 changed files with 15 additions and 10 deletions

3
NEWS
View File

@ -21,6 +21,9 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
information is stored in the ConfigSchema directory, and the information is stored in the ConfigSchema directory, and the
maintenance/generate-schema-cache.php generates the schema.ser file, which maintenance/generate-schema-cache.php generates the schema.ser file, which
is now instantiated. Support for userland schema changes coming soon! is now instantiated. Support for userland schema changes coming soon!
# HTMLPurifier_Config will now throw E_USER_NOTICE when you use a directive
alias; to get rid of these errors just modify your configuration to use
the new directive name.
! Extra utility classes for testing and non-library operations can ! Extra utility classes for testing and non-library operations can
be found in extras/. Specifically, these are FSTools and ConfigDoc. be found in extras/. Specifically, these are FSTools and ConfigDoc.
You may find a use for these in your own project, but right now they You may find a use for these in your own project, but right now they

1
TODO
View File

@ -27,7 +27,6 @@ DOCUMENTATION
IMPORTANT FEATURES IMPORTANT FEATURES
- Get everything into configuration objects (filters, I'm looking at you) - Get everything into configuration objects (filters, I'm looking at you)
- Factor out command line parser into its own class, and unit test it - Factor out command line parser into its own class, and unit test it
- Emit notices when aliases are used (allow muting these errors)
CONFIGDOC CONFIGDOC
- Properly integrate new ConfigSchema system into configdoc. DESCRIPTIONS - Properly integrate new ConfigSchema system into configdoc. DESCRIPTIONS

View File

@ -199,11 +199,13 @@ class HTMLPurifier_Config
if ($this->def->info[$namespace][$key]->class == 'alias') { if ($this->def->info[$namespace][$key]->class == 'alias') {
if ($from_alias) { if ($from_alias) {
trigger_error('Double-aliases not allowed, please fix '. trigger_error('Double-aliases not allowed, please fix '.
'ConfigSchema bug with' . "$namespace.$key"); 'ConfigSchema bug with' . "$namespace.$key", E_USER_ERROR);
return;
} }
$this->set($this->def->info[$namespace][$key]->namespace, $this->set($new_ns = $this->def->info[$namespace][$key]->namespace,
$this->def->info[$namespace][$key]->name, $new_dir = $this->def->info[$namespace][$key]->name,
$value, true); $value, true);
trigger_error("$namespace.$key is an alias, preferred directive name is $new_ns.$new_dir", E_USER_NOTICE);
return; return;
} }
try { try {

View File

@ -161,6 +161,7 @@ class HTMLPurifier_ConfigTest extends HTMLPurifier_Harness
$this->expectError('Cannot get value from aliased directive, use real name Home.Rug'); $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); $config->set('Home', 'Carpet', 999);
$this->assertIdentical($config->get('Home', 'Rug'), 999); $this->assertIdentical($config->get('Home', 'Rug'), 999);

View File

@ -160,7 +160,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_ComplexHarness
$this->config = HTMLPurifier_Config::createDefault(); $this->config = HTMLPurifier_Config::createDefault();
$this->config->set('Core', 'CommentScriptContents', false); $this->config->set('Output', 'CommentScriptContents', false);
$this->assertGeneration( $this->assertGeneration(
array( array(
@ -174,7 +174,7 @@ class HTMLPurifier_GeneratorTest extends HTMLPurifier_ComplexHarness
function test_generateFromTokens_XHTMLoff() { function test_generateFromTokens_XHTMLoff() {
$this->config = HTMLPurifier_Config::createDefault(); $this->config = HTMLPurifier_Config::createDefault();
$this->config->set('Core', 'XHTML', false); $this->config->set('HTML', 'XHTML', false);
// omit trailing slash // omit trailing slash
$this->assertGeneration( $this->assertGeneration(

View File

@ -6,7 +6,7 @@ class HTMLPurifier_HTMLModule_ScriptingTest extends HTMLPurifier_HTMLModuleHarne
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->config->set('HTML', 'Trusted', true); $this->config->set('HTML', 'Trusted', true);
$this->config->set('Core', 'CommentScriptContents', false); $this->config->set('Output', 'CommentScriptContents', false);
} }
function testDefaultRemoval() { function testDefaultRemoval() {

View File

@ -6,7 +6,7 @@ class HTMLPurifier_Strategy_ValidateAttributes_IDTest extends HTMLPurifier_Strat
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
$this->obj = new HTMLPurifier_Strategy_ValidateAttributes(); $this->obj = new HTMLPurifier_Strategy_ValidateAttributes();
$this->config->set('HTML', 'EnableAttrID', true); $this->config->set('Attr', 'EnableID', true);
} }

View File

@ -72,7 +72,7 @@ class HTMLPurifierTest extends HTMLPurifier_Harness
function testDisableURI() { function testDisableURI() {
$this->purifier = new HTMLPurifier( array('Attr.DisableURI' => true) ); $this->purifier = new HTMLPurifier( array('URI.Disable' => true) );
$this->assertPurification( $this->assertPurification(
'<img src="foobar"/>', '<img src="foobar"/>',
@ -105,7 +105,7 @@ class HTMLPurifierTest extends HTMLPurifier_Harness
'<span>foobar</span>' '<span>foobar</span>'
); );
$this->purifier = new HTMLPurifier(array('HTML.EnableAttrID' => true)); $this->purifier = new HTMLPurifier(array('Attr.EnableID' => true));
$this->assertPurification('<span id="moon">foobar</span>'); $this->assertPurification('<span id="moon">foobar</span>');
$this->assertPurification('<img id="folly" src="folly.png" alt="Omigosh!" />'); $this->assertPurification('<img id="folly" src="folly.png" alt="Omigosh!" />');