diff --git a/NEWS b/NEWS
index 68b3ad6e..a83e1b5e 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,8 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
to migrate an %HTML.AllowedAttributes directives to this syntax too.
! Allow index to be false for config from form creation
! Added HTMLPurifier::VERSION constant
+! Commas, not dashes, used for serializer IDs. This change is forwards-compatible
+ and allows for version numbers like "3.1.0-dev".
- InterchangeBuilder now alphabetizes its lists
- Validation error in configdoc output fixed
- Iconv and other encoding errors muted even with custom error handlers that
diff --git a/TODO b/TODO
index 9af74f95..bfd5a269 100644
--- a/TODO
+++ b/TODO
@@ -11,6 +11,9 @@ If no interest is expressed for a feature that may require 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!
+ - Get PH5P working with the latest versions of DOM, which have much more
+ stringent error checking procedures. Maybe convert straight to tokens.
+
FUTURE VERSIONS
---------------
diff --git a/configdoc/usage.xml b/configdoc/usage.xml
index 800180cc..19e2f621 100644
--- a/configdoc/usage.xml
+++ b/configdoc/usage.xml
@@ -131,12 +131,12 @@
- 326
+ 328
- 327
+ 329
diff --git a/library/HTMLPurifier/Config.php b/library/HTMLPurifier/Config.php
index bb854849..616ca06f 100644
--- a/library/HTMLPurifier/Config.php
+++ b/library/HTMLPurifier/Config.php
@@ -72,7 +72,7 @@ class HTMLPurifier_Config
* @param $definition HTMLPurifier_ConfigSchema that defines what directives
* are allowed.
*/
- public function __construct(&$definition) {
+ public function __construct($definition) {
$this->conf = $definition->defaults; // set up, copy in defaults
$this->def = $definition; // keep a copy around for checking
$this->parser = new HTMLPurifier_VarParser_Flexible();
diff --git a/library/HTMLPurifier/DefinitionCache.php b/library/HTMLPurifier/DefinitionCache.php
index 020b01c3..f81af0c5 100644
--- a/library/HTMLPurifier/DefinitionCache.php
+++ b/library/HTMLPurifier/DefinitionCache.php
@@ -26,8 +26,8 @@ abstract class HTMLPurifier_DefinitionCache
* @param Instance of HTMLPurifier_Config
*/
public function generateKey($config) {
- return $config->version . '-' . // possibly replace with function calls
- $config->getBatchSerial($this->type) . '-' .
+ return $config->version . ',' . // possibly replace with function calls
+ $config->getBatchSerial($this->type) . ',' .
$config->get($this->type, 'DefinitionRev');
}
@@ -38,8 +38,8 @@ abstract class HTMLPurifier_DefinitionCache
* @param $config Instance of HTMLPurifier_Config to test against
*/
public function isOld($key, $config) {
- if (substr_count($key, '-') < 2) return true;
- list($version, $hash, $revision) = explode('-', $key, 3);
+ if (substr_count($key, ',') < 2) return true;
+ list($version, $hash, $revision) = explode(',', $key, 3);
$compare = version_compare($version, $config->version);
// version mismatch, is always old
if ($compare != 0) return true;
diff --git a/library/HTMLPurifier/DefinitionCacheFactory.php b/library/HTMLPurifier/DefinitionCacheFactory.php
index 2d9aeca3..fca1b6c4 100644
--- a/library/HTMLPurifier/DefinitionCacheFactory.php
+++ b/library/HTMLPurifier/DefinitionCacheFactory.php
@@ -48,8 +48,7 @@ class HTMLPurifier_DefinitionCacheFactory
public function create($type, $config) {
$method = $config->get('Cache', 'DefinitionImpl');
if ($method === null) {
- $null = new HTMLPurifier_DefinitionCache_Null($type);
- return $null;
+ return new HTMLPurifier_DefinitionCache_Null($type);
}
if (!empty($this->caches[$method][$type])) {
return $this->caches[$method][$type];
diff --git a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
index 446bfc85..41765f7f 100644
--- a/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
+++ b/tests/HTMLPurifier/DefinitionCache/SerializerTest.php
@@ -11,7 +11,7 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$config->setReturnValue('get', 2, array('Test', 'DefinitionRev'));
$config->version = '1.0.0';
- $config_md5 = '1.0.0-serial-2';
+ $config_md5 = '1.0.0,serial,2';
$file = realpath(
$rel_file = HTMLPURIFIER_PREFIX . '/HTMLPurifier/DefinitionCache/Serializer/Test/' .
@@ -186,9 +186,9 @@ class HTMLPurifier_DefinitionCache_SerializerTest extends HTMLPurifier_Definitio
$def_original = $this->generateDefinition();
$cache->add($def_original, $config);
- $this->assertFileExist($dir . '/Test/1.0.0-serial-1.ser');
+ $this->assertFileExist($dir . '/Test/1.0.0,serial,1.ser');
- unlink($dir . '/Test/1.0.0-serial-1.ser');
+ unlink($dir . '/Test/1.0.0,serial,1.ser');
rmdir( $dir . '/Test');
}
diff --git a/tests/HTMLPurifier/DefinitionCacheTest.php b/tests/HTMLPurifier/DefinitionCacheTest.php
index 58ba8867..8e6d4378 100644
--- a/tests/HTMLPurifier/DefinitionCacheTest.php
+++ b/tests/HTMLPurifier/DefinitionCacheTest.php
@@ -13,16 +13,17 @@ class HTMLPurifier_DefinitionCacheTest extends HTMLPurifier_Harness
$config->setReturnValue('get', 10, array('Test', 'DefinitionRev'));
$config->setReturnValue('getBatchSerial', 'hash', array('Test'));
- $this->assertIdentical($cache->isOld('1.0.0-hash-10', $config), false);
- $this->assertIdentical($cache->isOld('1.5.0-hash-1', $config), true);
+ $this->assertIdentical($cache->isOld('1.0.0,hash,10', $config), false);
+ $this->assertIdentical($cache->isOld('1.5.0,hash,1', $config), true);
- $this->assertIdentical($cache->isOld('0.9.0-hash-1', $config), true);
- $this->assertIdentical($cache->isOld('1.0.0-hash-1', $config), true);
- $this->assertIdentical($cache->isOld('1.0.0beta-hash-11', $config), true);
+ $this->assertIdentical($cache->isOld('0.9.0,hash,1', $config), true);
+ $this->assertIdentical($cache->isOld('1.0.0,hash,1', $config), true);
+ $this->assertIdentical($cache->isOld('1.0.0beta,hash,11', $config), true);
- $this->assertIdentical($cache->isOld('0.9.0-hash2-1', $config), true);
- $this->assertIdentical($cache->isOld('1.0.0-hash2-1', $config), false); // if hash is different, don't touch!
- $this->assertIdentical($cache->isOld('1.0.0beta-hash2-11', $config), true);
+ $this->assertIdentical($cache->isOld('0.9.0,hash2,1', $config), true);
+ $this->assertIdentical($cache->isOld('1.0.0,hash2,1', $config), false); // if hash is different, don't touch!
+ $this->assertIdentical($cache->isOld('1.0.0beta,hash2,11', $config), true);
+ $this->assertIdentical($cache->isOld('1.0.0-dev,hash2,11', $config), true);
}
diff --git a/tests/HTMLPurifier/HTMLDefinitionTest.php b/tests/HTMLPurifier/HTMLDefinitionTest.php
index 5b4f5e77..35048ab0 100644
--- a/tests/HTMLPurifier/HTMLDefinitionTest.php
+++ b/tests/HTMLPurifier/HTMLDefinitionTest.php
@@ -3,6 +3,13 @@
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);
+ parent::expectError($error);
+ }
+
function test_parseTinyMCEAllowedList() {
$def = new HTMLPurifier_HTMLDefinition();
@@ -85,21 +92,18 @@ a[href|title]
}
function test_AllowedElements_invalidElement() {
- $this->config->set('Cache', 'DefinitionImpl', null); // Necessary to ensure error is thrown
$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('Cache', 'DefinitionImpl', null);
$this->config->set('HTML', 'AllowedElements', '