diff --git a/library/HTMLPurifier/AttrDef.php b/library/HTMLPurifier/AttrDef.php index ad7ab384..754d995a 100644 --- a/library/HTMLPurifier/AttrDef.php +++ b/library/HTMLPurifier/AttrDef.php @@ -8,6 +8,13 @@ class HTMLPurifier_AttrDef function validate() { trigger_error('Cannot call abstract function', E_USER_ERROR); } + + function parseCDATA($string) { + $string = trim($string); + $string = str_replace("\n", '', $string); + $string = str_replace(array("\r", "\t"), ' ', $string); + return $string; + } } ?> \ No newline at end of file diff --git a/library/HTMLPurifier/AttrDef/Text.php b/library/HTMLPurifier/AttrDef/Text.php new file mode 100644 index 00000000..5d9a3669 --- /dev/null +++ b/library/HTMLPurifier/AttrDef/Text.php @@ -0,0 +1,15 @@ +parseCDATA($string); + return ($string == $new_string) ? true : $new_string; + } + +} + +?> \ No newline at end of file diff --git a/library/HTMLPurifier/Definition.php b/library/HTMLPurifier/Definition.php index 255ff4ff..6af372ec 100644 --- a/library/HTMLPurifier/Definition.php +++ b/library/HTMLPurifier/Definition.php @@ -3,6 +3,8 @@ 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/Text.php'; require_once 'HTMLPurifier/ChildDef.php'; require_once 'HTMLPurifier/Generator.php'; require_once 'HTMLPurifier/Token.php'; @@ -238,6 +240,7 @@ class HTMLPurifier_Definition // core attrs 'id' => new HTMLPurifier_AttrDef_ID(), 'class' => new HTMLPurifier_AttrDef_Class(), + 'title' => new HTMLPurifier_AttrDef_Text(), // i18n 'dir' => new HTMLPurifier_AttrDef_Enum(array('ltr','rtl'), false), ); diff --git a/tests/HTMLPurifier/AttrDef/TextTest.php b/tests/HTMLPurifier/AttrDef/TextTest.php new file mode 100644 index 00000000..8d8c2694 --- /dev/null +++ b/tests/HTMLPurifier/AttrDef/TextTest.php @@ -0,0 +1,20 @@ +assertTrue($def->validate('This is spiffy text!')); + $this->assertEqual('Casual CDATA parsecheck.', + $def->validate(" Casual\tCDATA parse\ncheck. ")); + + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/AttrDefTest.php b/tests/HTMLPurifier/AttrDefTest.php new file mode 100644 index 00000000..ff4ad725 --- /dev/null +++ b/tests/HTMLPurifier/AttrDefTest.php @@ -0,0 +1,22 @@ +assertEqual('', $def->parseCDATA('')); + $this->assertEqual('', $def->parseCDATA("\t\n\r \t\t")); + $this->assertEqual('foo', $def->parseCDATA("\t\n\r foo\t\t")); + $this->assertEqual('ignorelinefeeds', $def->parseCDATA("ignore\nline\nfeeds")); + $this->assertEqual('translate to space', $def->parseCDATA("translate\rto\tspace")); + + } + +} + +?> \ No newline at end of file diff --git a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php index e59c3927..7f12ff9e 100644 --- a/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php +++ b/tests/HTMLPurifier/Strategy/ValidateAttributesTest.php @@ -52,6 +52,13 @@ class HTMLPurifier_Strategy_ValidateAttributesTest extends $inputs[8] = '