mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 16:31:53 +00:00
[1.5.0] Rename Class to Nmtokens (more accurate)
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@706 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
f90eef7f1f
commit
806901cfd2
1
NEWS
1
NEWS
@ -13,6 +13,7 @@ NEWS ( CHANGELOG and HISTORY ) HTMLPurifier
|
||||
! Added a rudimentary I18N and L10N system modeled off MediaWiki
|
||||
- Allow 'x' subtag in language codes
|
||||
. Added support for IDREF attributes (i.e. for)
|
||||
. Renamed HTMLPurifier_AttrDef_Class to HTMLPurifier_AttrDef_Nmtokens
|
||||
|
||||
1.4.2, unknown release date
|
||||
! docs/enduser-utf8.html explains how to use UTF-8 and HTML Purifier
|
||||
|
@ -4,9 +4,13 @@ require_once 'HTMLPurifier/AttrDef.php';
|
||||
require_once 'HTMLPurifier/Config.php';
|
||||
|
||||
/**
|
||||
* Validates the contents of the global HTML attribute class.
|
||||
* Validates contents based on NMTOKENS attribute type.
|
||||
* @note The only current use for this is the class attribute in HTML
|
||||
* @note Could have some functionality factored out into Nmtoken class
|
||||
* @warning We cannot assume this class will be used only for 'class'
|
||||
* attributes. Not sure how to hook in magic behavior, then.
|
||||
*/
|
||||
class HTMLPurifier_AttrDef_Class extends HTMLPurifier_AttrDef
|
||||
class HTMLPurifier_AttrDef_Nmtokens extends HTMLPurifier_AttrDef
|
||||
{
|
||||
|
||||
function validate($string, $config, &$context) {
|
||||
@ -31,10 +35,10 @@ class HTMLPurifier_AttrDef_Class extends HTMLPurifier_AttrDef
|
||||
|
||||
if (empty($matches[1])) return false;
|
||||
|
||||
// reconstruct class string
|
||||
// reconstruct string
|
||||
$new_string = '';
|
||||
foreach ($matches[1] as $class_names) {
|
||||
$new_string .= $class_names . ' ';
|
||||
foreach ($matches[1] as $token) {
|
||||
$new_string .= $token . ' ';
|
||||
}
|
||||
$new_string = rtrim($new_string);
|
||||
|
@ -3,7 +3,7 @@
|
||||
require_once 'HTMLPurifier/AttrDef.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Enum.php';
|
||||
require_once 'HTMLPurifier/AttrDef/ID.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Class.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Nmtokens.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Text.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Lang.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Pixels.php';
|
||||
@ -398,7 +398,7 @@ class HTMLPurifier_HTMLDefinition
|
||||
// which manually override these in their local definitions
|
||||
$this->info_global_attr = array(
|
||||
// core attrs
|
||||
'class' => new HTMLPurifier_AttrDef_Class(),
|
||||
'class' => new HTMLPurifier_AttrDef_Nmtokens(),
|
||||
'title' => $e_Text,
|
||||
'style' => new HTMLPurifier_AttrDef_CSS(),
|
||||
// i18n
|
||||
|
@ -1,15 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDefHarness.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Class.php';
|
||||
require_once 'HTMLPurifier/AttrDef/Nmtokens.php';
|
||||
require_once 'HTMLPurifier/Config.php';
|
||||
|
||||
class HTMLPurifier_AttrDef_ClassTest extends HTMLPurifier_AttrDefHarness
|
||||
class HTMLPurifier_AttrDef_NmtokensTest extends HTMLPurifier_AttrDefHarness
|
||||
{
|
||||
|
||||
function testDefault() {
|
||||
|
||||
$this->def = new HTMLPurifier_AttrDef_Class();
|
||||
$this->def = new HTMLPurifier_AttrDef_Nmtokens();
|
||||
|
||||
$this->assertDef('valid');
|
||||
$this->assertDef('a0-_');
|
@ -25,7 +25,7 @@ $test_files[] = 'Strategy/ValidateAttributesTest.php';
|
||||
$test_files[] = 'AttrDefTest.php';
|
||||
$test_files[] = 'AttrDef/EnumTest.php';
|
||||
$test_files[] = 'AttrDef/IDTest.php';
|
||||
$test_files[] = 'AttrDef/ClassTest.php';
|
||||
$test_files[] = 'AttrDef/NmtokensTest.php';
|
||||
$test_files[] = 'AttrDef/TextTest.php';
|
||||
$test_files[] = 'AttrDef/LangTest.php';
|
||||
$test_files[] = 'AttrDef/PixelsTest.php';
|
||||
|
Loading…
Reference in New Issue
Block a user