1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-31 19:30:21 +02:00

Massively refactored Definition, moved MakeWellFormed HTML specific code out.

Add table functionality for nesting, don't know how I missed that. It's still broken though.

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@135 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2006-07-31 00:15:01 +00:00
parent 2b5589c884
commit 9c6ae16764
3 changed files with 91 additions and 64 deletions

View File

@@ -59,35 +59,19 @@ class HTMLPurifier_Strategy_MakeWellFormed extends HTMLPurifier_Strategy
// if there's a parent, check for special case
if (!empty($current_nesting)) {
$current_parent = array_pop($current_nesting);
// this ought to be moved to definition
$parent = array_pop($current_nesting);
$parent_name = $parent->name;
$parent_info = $this->definition->info[$parent_name];
// check if we're closing a P tag
if ($current_parent->name == 'p' &&
isset($this->definition->info_closes_p[$token->name])
) {
$result[] = new HTMLPurifier_Token_End('p');
if (isset($parent_info->auto_close[$token->name])) {
$result[] = new HTMLPurifier_Token_End($parent_name);
$result[] = $token;
$current_nesting[] = $token;
continue;
}
// check if we're closing a LI tag
if ($current_parent->name == 'li' &&
$token->name == 'li'
) {
$result[] = new HTMLPurifier_Token_End('li');
$result[] = $token;
$current_nesting[] = $token;
continue;
}
// this is more TIDY stuff
// we should also get some TABLE related code
// mismatched h#
$current_nesting[] = $current_parent; // undo the pop
$current_nesting[] = $parent; // undo the pop
}
$result[] = $token;