mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-04 21:28:06 +02:00
Define AttrDef_Text and parseCDATA().
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@160 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
15
library/HTMLPurifier/AttrDef/Text.php
Normal file
15
library/HTMLPurifier/AttrDef/Text.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/AttrDef.php';
|
||||
|
||||
class HTMLPurifier_AttrDef_Text extends HTMLPurifier_AttrDef
|
||||
{
|
||||
|
||||
function validate($string) {
|
||||
$new_string = $this->parseCDATA($string);
|
||||
return ($string == $new_string) ? true : $new_string;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@@ -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),
|
||||
);
|
||||
|
Reference in New Issue
Block a user