本文整理汇总了PHP中Sanitizer::validateTag方法的典型用法代码示例。如果您正苦于以下问题:PHP Sanitizer::validateTag方法的具体用法?PHP Sanitizer::validateTag怎么用?PHP Sanitizer::validateTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sanitizer
的用法示例。
在下文中一共展示了Sanitizer::validateTag方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeHTMLtags
//.........这里部分代码省略.........
MediaWiki\restoreWarnings();
}
}
} else {
MediaWiki\suppressWarnings();
array_push($tagstack, $ot);
MediaWiki\restoreWarnings();
# <li> can be nested in <ul> or <ol>, skip those cases:
if (!isset($htmllist[$ot]) || !isset($listtags[$t])) {
$badtag = true;
}
}
} else {
if ($t == 'table') {
$tagstack = array_pop($tablestack);
}
}
$newparams = '';
} else {
# Keep track for later
if (isset($tabletags[$t]) && !in_array('table', $tagstack)) {
$badtag = true;
} elseif (in_array($t, $tagstack) && !isset($htmlnest[$t])) {
$badtag = true;
# Is it a self closed htmlpair ? (bug 5487)
} elseif ($brace == '/>' && isset($htmlpairs[$t])) {
$badtag = true;
} elseif (isset($htmlsingleonly[$t])) {
# Hack to force empty tag for unclosable elements
$brace = '/>';
} elseif (isset($htmlsingle[$t])) {
# Hack to not close $htmlsingle tags
$brace = null;
# Still need to push this optionally-closed tag to
# the tag stack so that we can match end tags
# instead of marking them as bad.
array_push($tagstack, $t);
} elseif (isset($tabletags[$t]) && in_array($t, $tagstack)) {
// New table tag but forgot to close the previous one
$text .= "</{$t}>";
} else {
if ($t == 'table') {
array_push($tablestack, $tagstack);
$tagstack = array();
}
array_push($tagstack, $t);
}
# Replace any variables or template parameters with
# plaintext results.
if (is_callable($processCallback)) {
call_user_func_array($processCallback, array(&$params, $args));
}
if (!Sanitizer::validateTag($params, $t)) {
$badtag = true;
}
# Strip non-approved attributes from the tag
$newparams = Sanitizer::fixTagAttributes($params, $t);
}
if (!$badtag) {
$rest = str_replace('>', '>', $rest);
$close = $brace == '/>' && !$slash ? ' /' : '';
$text .= "<{$slash}{$t}{$newparams}{$close}>{$rest}";
continue;
}
}
$text .= '<' . str_replace('>', '>', $x);
}
# Close off any remaining tags
while (is_array($tagstack) && ($t = array_pop($tagstack))) {
$text .= "</{$t}>\n";
if ($t == 'table') {
$tagstack = array_pop($tablestack);
}
}
} else {
# this might be possible using tidy itself
foreach ($bits as $x) {
if (preg_match(self::ELEMENT_BITS_REGEX, $x, $regs)) {
list(, $slash, $t, $params, $brace, $rest) = $regs;
$badtag = false;
if (isset($htmlelements[$t = strtolower($t)])) {
if (is_callable($processCallback)) {
call_user_func_array($processCallback, array(&$params, $args));
}
if (!Sanitizer::validateTag($params, $t)) {
$badtag = true;
}
$newparams = Sanitizer::fixTagAttributes($params, $t);
if (!$badtag) {
$rest = str_replace('>', '>', $rest);
$text .= "<{$slash}{$t}{$newparams}{$brace}{$rest}";
continue;
}
}
}
$text .= '<' . str_replace('>', '>', $x);
}
}
return $text;
}
示例2: removeHTMLtags
//.........这里部分代码省略.........
wfSuppressWarnings();
$ot = array_pop($optstack);
wfRestoreWarnings();
}
}
} else {
@array_push($tagstack, $ot);
# <li> can be nested in <ul> or <ol>, skip those cases:
if (!isset($htmllist[$ot]) || !isset($listtags[$t])) {
$badtag = true;
}
}
} else {
if ($t == 'table') {
$tagstack = array_pop($tablestack);
}
}
$newparams = '';
} else {
# Keep track for later
if (isset($tabletags[$t]) && !in_array('table', $tagstack)) {
$badtag = true;
} elseif (in_array($t, $tagstack) && !isset($htmlnest[$t])) {
$badtag = true;
# Is it a self closed htmlpair ? (bug 5487)
} elseif ($brace == '/>' && isset($htmlpairs[$t])) {
$badtag = true;
} elseif (isset($htmlsingleonly[$t])) {
# Hack to force empty tag for unclosable elements
$brace = '/>';
} elseif (isset($htmlsingle[$t])) {
# Hack to not close $htmlsingle tags
$brace = null;
# Still need to push this optionally-closed tag to
# the tag stack so that we can match end tags
# instead of marking them as bad.
array_push($tagstack, $t);
} elseif (isset($tabletags[$t]) && in_array($t, $tagstack)) {
// New table tag but forgot to close the previous one
$text .= "</{$t}>";
} else {
if ($t == 'table') {
array_push($tablestack, $tagstack);
$tagstack = array();
}
array_push($tagstack, $t);
}
# Replace any variables or template parameters with
# plaintext results.
if (is_callable($processCallback)) {
call_user_func_array($processCallback, array(&$params, $args));
}
if (!Sanitizer::validateTag($params, $t)) {
$badtag = true;
}
# Strip non-approved attributes from the tag
$newparams = Sanitizer::fixTagAttributes($params, $t);
}
if (!$badtag) {
$rest = str_replace('>', '>', $rest);
$close = $brace == '/>' && !$slash ? ' /' : '';
$text .= "<{$slash}{$t}{$newparams}{$close}>{$rest}";
continue;
}
}
$text .= '<' . str_replace('>', '>', $x);
}
# Close off any remaining tags
while (is_array($tagstack) && ($t = array_pop($tagstack))) {
$text .= "</{$t}>\n";
if ($t == 'table') {
$tagstack = array_pop($tablestack);
}
}
} else {
# this might be possible using tidy itself
foreach ($bits as $x) {
preg_match('/^(\\/?)(\\w+)([^>]*?)(\\/{0,1}>)([^<]*)$/', $x, $regs);
@(list(, $slash, $t, $params, $brace, $rest) = $regs);
$badtag = false;
if (isset($htmlelements[$t = strtolower($t)])) {
if (is_callable($processCallback)) {
call_user_func_array($processCallback, array(&$params, $args));
}
if (!Sanitizer::validateTag($params, $t)) {
$badtag = true;
}
$newparams = Sanitizer::fixTagAttributes($params, $t);
if (!$badtag) {
$rest = str_replace('>', '>', $rest);
$text .= "<{$slash}{$t}{$newparams}{$brace}{$rest}";
continue;
}
}
$text .= '<' . str_replace('>', '>', $x);
}
}
wfProfileOut(__METHOD__);
return $text;
}