diff --git a/TODO b/TODO index 67bcfe24..6cc9f895 100644 --- a/TODO +++ b/TODO @@ -7,13 +7,12 @@ TODO List ? Maybe I'll Do It ========================== +If no interest is expressed for a feature that may required a considerable +amount of effort to implement, it may get endlessly delayed. Do not be +afraid to cast your vote for the next feature to be implemented! + 2.1 release [Refactor, refactor!] - # URI validation routines tighter (see docs/dev-code-quality.html) (COMPLEX) - # Advanced URI filtering schemes (see docs/proposal-new-directives.txt) - # Ruby support - Configuration profiles: predefined directives set with one func call - - Implement IDREF support (harder than it seems, since you cannot have - IDREFs to non-existent IDs) - Allow non-ASCII characters in font names - Explain how to use HTML Purifier in non-PHP languages / create a simple command line stub @@ -39,6 +38,8 @@ TODO List 2.4 release [It's All About Trust] (floating) # Implement untrusted, dangerous elements/attributes + # Implement IDREF support (harder than it seems, since you cannot have + IDREFs to non-existent IDs) 3.0 release [Beyond HTML] # Legit token based CSS parsing (will require revamping almost every @@ -77,6 +78,8 @@ Unknown release (on a scratch-an-itch basis) - Reorganize Unit Tests - Refactor loop tests: Lexer - Reorganize configuration directives (Create more namespaces! Get messy!) + - Advanced URI filtering schemes (see docs/proposal-new-directives.txt) + - Implement lenient child validation Requested diff --git a/docs/dev-code-quality.txt b/docs/dev-code-quality.txt index 7c09a22c..10e21cb7 100644 --- a/docs/dev-code-quality.txt +++ b/docs/dev-code-quality.txt @@ -11,8 +11,7 @@ docs/examples/demo.php - ad hoc HTML/PHP soup to the extreme AttrDef - a lot of duplication, more generic classes need to be created; a lot of strtolower() calls, no legit casing - Class - doesn't support Unicode characters (fringe); uses regular - expressions + Class - doesn't support Unicode characters (fringe); uses regular expressions Lang - code duplication; premature optimization Length - easily mistaken for CSSLength URI - multiple regular expressions; missing validation for parts (?) @@ -22,9 +21,6 @@ ConfigSchema - redefinition is a mess Strategy FixNesting - cannot bubble nodes out of structures, duplicated checks for special-case parent node - MakeWellFormed - insufficient automatic closing definitions (check HTML - spec for optional end tags, also, closing based on type (block/inline) - might be efficient). RemoveForeignElements - should be run in parallel with MakeWellFormed URIScheme - needs to have callable generic checks mailto - doesn't validate emails, doesn't validate querystring diff --git a/docs/proposal-new-directives.txt b/docs/proposal-new-directives.txt index b3351b4c..1ce1b93b 100644 --- a/docs/proposal-new-directives.txt +++ b/docs/proposal-new-directives.txt @@ -2,7 +2,8 @@ Configuration Ideas Here are some theoretical configuration ideas that we could implement some -time. Note the naming convention: %Namespace.Directive +time. Note the naming convention: %Namespace.Directive. If you want one +implemented, give us a ring, and we'll move it up the priority chain. %Attr.RewriteFragments - if there's %Attr.IDPrefix we may want to transparently rewrite the URLs we parse too. However, we can only do it when it's a pure diff --git a/library/HTMLPurifier/HTMLModule/Ruby.php b/library/HTMLPurifier/HTMLModule/Ruby.php new file mode 100644 index 00000000..f5432446 --- /dev/null +++ b/library/HTMLPurifier/HTMLModule/Ruby.php @@ -0,0 +1,28 @@ +addElement('ruby', true, 'Inline', + 'Custom: ((rb, (rt | (rp, rt, rp))) | (rbc, rtc, rtc?))', + 'Common'); + $this->addElement('rbc', true, false, 'Required: rb', 'Common'); + $this->addElement('rtc', true, false, 'Required: rt', 'Common'); + $rb =& $this->addElement('rb', true, false, 'Inline', 'Common'); + $rb->excludes = array('ruby' => true); + $rt =& $this->addElement('rt', true, false, 'Inline', 'Common', array('rbspan' => 'Number')); + $rt->excludes = array('ruby' => true); + $this->addElement('rp', true, false, 'Optional: #PCDATA', 'Common'); + } + +} + diff --git a/library/HTMLPurifier/HTMLModuleManager.php b/library/HTMLPurifier/HTMLModuleManager.php index c0326a16..d4f10d0c 100644 --- a/library/HTMLPurifier/HTMLModuleManager.php +++ b/library/HTMLPurifier/HTMLModuleManager.php @@ -28,6 +28,7 @@ require_once 'HTMLPurifier/HTMLModule/Target.php'; require_once 'HTMLPurifier/HTMLModule/Scripting.php'; require_once 'HTMLPurifier/HTMLModule/XMLCommonAttributes.php'; require_once 'HTMLPurifier/HTMLModule/NonXMLCommonAttributes.php'; +require_once 'HTMLPurifier/HTMLModule/Ruby.php'; // tidy modules require_once 'HTMLPurifier/HTMLModule/Tidy.php'; @@ -215,7 +216,7 @@ class HTMLPurifier_HTMLModuleManager $this->doctypes->register( 'XHTML 1.1', true, - array_merge($common, $xml), + array_merge($common, $xml, array('Ruby')), array('Tidy_Strict', 'Tidy_XHTML', 'Tidy_Proprietary', 'Tidy_XHTMLStrict'), // Tidy_XHTML1_1 array(), '-//W3C//DTD XHTML 1.1//EN', diff --git a/library/HTMLPurifier/Strategy/ValidateAttributes.php b/library/HTMLPurifier/Strategy/ValidateAttributes.php index 4b3d7486..869f3fab 100644 --- a/library/HTMLPurifier/Strategy/ValidateAttributes.php +++ b/library/HTMLPurifier/Strategy/ValidateAttributes.php @@ -46,6 +46,7 @@ class HTMLPurifier_Strategy_ValidateAttributes extends HTMLPurifier_Strategy } $context->destroy('IDAccumulator'); + $context->destroy('CurrentToken'); return $tokens; } diff --git a/tests/HTMLPurifier/ComplexHarness.php b/tests/HTMLPurifier/ComplexHarness.php index 5e2e22e2..8ea7378d 100644 --- a/tests/HTMLPurifier/ComplexHarness.php +++ b/tests/HTMLPurifier/ComplexHarness.php @@ -74,6 +74,7 @@ class HTMLPurifier_ComplexHarness extends HTMLPurifier_Harness // setup config if ($this->config) { $config = HTMLPurifier_Config::create($this->config); + $config->autoFinalize = false; $config->loadArray($config_array); } else { $config = HTMLPurifier_Config::create($config_array); diff --git a/tests/HTMLPurifier/HTMLModule/RubyTest.php b/tests/HTMLPurifier/HTMLModule/RubyTest.php new file mode 100644 index 00000000..15abbcb7 --- /dev/null +++ b/tests/HTMLPurifier/HTMLModule/RubyTest.php @@ -0,0 +1,56 @@ +config->set('HTML', 'Doctype', 'XHTML 1.1'); + } + + function testBasicUse() { + $this->assertResult( + 'WWWWorld Wide Web' + ); + } + + function testRPUse() { + $this->assertResult( + 'WWW(World Wide Web)' + ); + } + + function testComplexUse() { + $this->assertResult( +' + + 10 + 31 + 2002 + + + Month + Day + Year + + + Expiration Date + +' + ); + + /* not implemented + function testBackwardsCompat() { + $this->assertResult( + 'A(aaa)', + 'A(aaa)' + ); + } + */ + + } + +} + diff --git a/tests/HTMLPurifier/Strategy/FixNestingTest.php b/tests/HTMLPurifier/Strategy/FixNestingTest.php index 2a323c57..ac651684 100644 --- a/tests/HTMLPurifier/Strategy/FixNestingTest.php +++ b/tests/HTMLPurifier/Strategy/FixNestingTest.php @@ -63,12 +63,6 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness 'Not allowed!' ); - $this->assertResult( // alt config - '
Not allowed!
', - '<div>Not allowed!</div>', - array('Core.EscapeInvalidChildren' => true) - ); - // test block element that has inline content $this->assertResult( '

Not allowed!

', @@ -84,6 +78,12 @@ class HTMLPurifier_Strategy_FixNestingTest extends HTMLPurifier_StrategyHarness '
Allowed!
' ); + $this->assertResult( // alt config + '
Not allowed!
', + '<div>Not allowed!</div>', + array('Core.EscapeInvalidChildren' => true) + ); + } function testExclusionsIntegration() { diff --git a/tests/HTMLPurifier/StrategyHarness.php b/tests/HTMLPurifier/StrategyHarness.php index 72b3c22c..fe20b646 100644 --- a/tests/HTMLPurifier/StrategyHarness.php +++ b/tests/HTMLPurifier/StrategyHarness.php @@ -6,6 +6,7 @@ class HTMLPurifier_StrategyHarness extends HTMLPurifier_ComplexHarness { function setUp() { + parent::setUp(); $this->func = 'execute'; $this->to_tokens = true; $this->to_html = true; diff --git a/tests/test_files.php b/tests/test_files.php index 93766376..f9fa71c1 100644 --- a/tests/test_files.php +++ b/tests/test_files.php @@ -79,6 +79,7 @@ $test_files[] = 'HTMLPurifier/GeneratorTest.php'; $test_files[] = 'HTMLPurifier/HTMLDefinitionTest.php'; $test_files[] = 'HTMLPurifier/HTMLModuleManagerTest.php'; $test_files[] = 'HTMLPurifier/HTMLModuleTest.php'; +$test_files[] = 'HTMLPurifier/HTMLModule/RubyTest.php'; $test_files[] = 'HTMLPurifier/HTMLModule/ScriptingTest.php'; $test_files[] = 'HTMLPurifier/HTMLModule/TidyTest.php'; $test_files[] = 'HTMLPurifier/IDAccumulatorTest.php';