* @warning validateChildren() in this class is actually never called, because
* empty elements are corrected in HTMLPurifier_Strategy_MakeWellFormed
*/
class HTMLPurifier_ChildDef_Empty extends HTMLPurifier_ChildDef
{
public $allow_empty = true;
public $type = 'empty';
public function __construct() {}
if (!isset($tokens[$t])) {
// kill processing if stack is empty
if (empty($this->stack)) break;
// quick-check: if it's not a tag, no need to process
if (empty($token->is_tag)) {
$ok = false;
if ($type === 'empty' && $token instanceof HTMLPurifier_Token_Start) {
// claims to be a start tag but is empty
$token = new HTMLPurifier_Token_Empty($token->name, $token->attr, $token->line, $token->col, $token->armor);
$ok = true;
} elseif ($type && $type !== 'empty' && $token instanceof HTMLPurifier_Token_Empty) {
// claims to be empty but really is a start tag
// make sure that we have something open
if (empty($this->stack)) {
// seperate out parts
$scheme = !empty($matches[1]) ? $matches[2] : null;
$authority = !empty($matches[3]) ? $matches[4] : null;
$path = $matches[5]; // always present, can be empty
$query = !empty($matches[6]) ? $matches[7] : null;
$fragment = !empty($matches[8]) ? $matches[9] : null;
preg_match($r_authority, $authority, $matches);
$userinfo = !empty($matches[1]) ? $matches[2] : null;
$host = !empty($matches[3]) ? $matches[3] : '';
$port = !empty($matches[4]) ? (int) $matches[5] : null;
} else {
*
* @note Any empty elements will have empty tokens associated with them, even if
do {
while (!empty($nodes[$level])) {
// We still have to make sure that the element actually IS empty
if ($collect) {
$tokens[] = $this->factory->createEmpty($node->tagName, $attr);
if (!empty($def->doctype->dtdPublic) || !empty($def->doctype->dtdSystem)) {
$ret .= '<!DOCTYPE html ';
if (!empty($def->doctype->dtdPublic)) $ret .= 'PUBLIC "' . $def->doctype->dtdPublic . '" ';
if (!empty($def->doctype->dtdSystem)) $ret .= '"' . $def->doctype->dtdSystem . '" ';
$ret .= '>';
// but it is only populated when an element with exclusions is
// processed, i.e. there won't be empty exclusions.
// check if conditions make it inline
if (!empty($parent_def) && $parent_def->descendants_are_inline) {
$excluded = false;
if (!empty($exclude_stack)) {
if (!empty($def->child)) {
// register exclusions if there are any
if (!empty($excludes)) $exclude_stack[] = $excludes;
// our current implementation claims that that case would
// not allow empty, even if it did
if (!$parent_def->child->allow_empty) {
// we need to do a double-check
// register exclusions if there are any
if (!empty($excludes)) $exclude_stack[] = $excludes;
if ($this->allowsElement('p')) {
if (empty($this->currentNesting) || strpos($text, "\n\n") !== false) {
} elseif (
!empty($this->currentNesting) &&
if ($this->allowsElement('p')) {
if (!empty($this->currentNesting)) {
$raw_paragraphs = explode("\n\n", $data);
$paragraphs = array(); // without empty paragraphs
// Double newline at the front
if (empty($result)) {
// The empty result indicates that the AutoParagraph
// injector did not add any start paragraph tokens.
// perhaps?
if (empty($paragraphs)) {
'diams;','divide;','divide','eacute;','eacute','ecirc;','ecirc','egrave;',
'egrave','empty;','emsp;','ensp;','epsilon;','equiv;','eta;','eth;','eth',
Start a new attribute in the current tag token. Set that attribute's
name to the current input character, and its value to the empty string.
Start a new attribute in the current tag token. Set that attribute's
name to the current input character, and its value to the empty string.
end of the file otherwise. (If the comment was started by the end of
the file (EOF), the token is empty.) */
characters, consume those two characters, create a comment token whose
data is the empty string, and switch to the comment state. */
"HTML"), and the other attributes specific to DocumentType objects
set to null, empty lists, or the empty string as appropriate. */
public function getBatchSerial($namespace) {
if (empty($this->serials[$namespace])) {
public function getSerial() {
if (empty($this->serial)) {
// check if definition is in memory
if (!empty($this->definitions[$type])) {
}
if (!empty($this->definitions[$type])) {
$skey = "$ns.$directive";
if (!empty($array["Null_$skey"])) {
/**
* Definition that allows a set of elements, but disallows empty children.
$elements[$i] = true;
if (empty($i)) unset($elements[$i]); // remove blank
}
public $allow_empty = false;
// if there are no tokens, delete parent node
if (empty($tokens_of_children)) return false;
foreach ($tokens_of_children as $token) {
if (!empty($token->is_whitespace)) {
}
if (empty($result)) return false;
{
public $allow_empty = false;
public function validateChildren($tokens_of_children, $config, $context) {
if (empty($tokens_of_children)) return false;
if ($token->name == 'col') {
// the only empty tag in the possie, we can handle it
default:
if (!empty($token->is_whitespace)) {
if (empty($content)) return false;
foreach ($content as $token_array) $ret = array_merge($ret, $token_array);
if (!empty($collection) && $is_collecting == false){
if ($this->_flashCompat) {
if ($token->name == "object" && !empty($this->_flashStack)) {
} elseif ($token instanceof HTMLPurifier_Token_Empty) {
if ($this->_flashCompat && $token->name == "param" && !empty($this->_flashStack)) {
$this->_flashStack[count($this->_flashStack)-1]->param[$token->attr['name']] = $token->attr['value'];
// Check if we should minimize the attribute: val="val" -> val
if ($element && !empty($this->_def->info[$element]->attr[$key]->minimized)) {
require_once $__dir . '/HTMLPurifier/ChildDef/Custom.php';
require_once $__dir . '/HTMLPurifier/ChildDef/Empty.php';
require_once $__dir . '/HTMLPurifier/Injector/PurifierLinkify.php';
require_once $__dir . '/HTMLPurifier/Injector/RemoveEmpty.php';
require_once $__dir . '/HTMLPurifier/Token/Tag.php';
require_once $__dir . '/HTMLPurifier/Token/Empty.php';