mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-09 15:28:40 +00:00
Begin creating scaffolding for the DTD declarations + evaluations that will make up the meat of the rest of the validation. Add a few more forgotten tests for makeWellFormed()
git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@38 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
3f4d928173
commit
4c9f4067ab
@ -155,7 +155,12 @@ class PureHTMLDefinition
|
||||
|
||||
function makeWellFormed($tokens) {
|
||||
if (empty($this->info)) $this->loadData();
|
||||
|
||||
$result = array();
|
||||
$current_nesting = array();
|
||||
foreach ($tokens as $token) {
|
||||
if (!is_subclass_of($token, 'MF_Tag')) $result[] = $token;
|
||||
// test if it claims to be a start tag but is empty
|
||||
}
|
||||
}
|
||||
|
||||
function fixNesting($tokens) {
|
||||
@ -170,4 +175,44 @@ class PureHTMLDefinition
|
||||
|
||||
}
|
||||
|
||||
class HTMLDTD_Element
|
||||
{
|
||||
|
||||
var $child_def;
|
||||
var $attr_def = array();
|
||||
|
||||
|
||||
}
|
||||
|
||||
class HTMLDTD_ChildDef {
|
||||
var $dtd_regex;
|
||||
function HTMLDTD_ChildDef($dtd_regex) {
|
||||
$this->dtd_regex = $dtd_regex;
|
||||
}
|
||||
function validateChildren($tokens_of_children) {}
|
||||
}
|
||||
class HTMLDTD_ChildDef_Simple extends HTMLDTD_ChildDef {
|
||||
var $elements = array();
|
||||
function HTMLDTD_ChildDef_Simple($elements) {
|
||||
$this->elements = $elements;
|
||||
}
|
||||
}
|
||||
class HTMLDTD_ChildDef_Required extends HTMLDTD_ChildDef_Simple {
|
||||
function validateChildren($tokens_of_children) {
|
||||
|
||||
}
|
||||
}
|
||||
class HTMLDTD_ChildDef_Optional extends HTMLDTD_ChildDef_Simple {
|
||||
function validateChildren($tokens_of_children) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class HTMLDTD_AttrDef {
|
||||
var $def;
|
||||
function HTMLDTD_AttrDef($def) {
|
||||
$this->def = $def;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -109,6 +109,15 @@ class Test_PureHTMLDefinition extends UnitTestCase
|
||||
,new MF_Text('</b>')
|
||||
);
|
||||
|
||||
$inputs[5] = array(new MF_StartTag('br'));
|
||||
$expect[5] = array(new MF_EmptyTag('br'));
|
||||
|
||||
$inputs[6] = array(new MF_EmptyTag('div'));
|
||||
$expect[6] = array(
|
||||
new MF_StartTag('div')
|
||||
,new MF_EndTag('div')
|
||||
);
|
||||
|
||||
foreach ($inputs as $i => $input) {
|
||||
$result = $this->def->removeForeignElements($input);
|
||||
$this->assertEqual($expect[$i], $result);
|
||||
|
Loading…
Reference in New Issue
Block a user