33 const VOID_ELEMENTS =
'area|base|br|col|command|embed|hr|img|input|keygen|meta|param|source|track|wbr';
51 public function splitIntoBlock($tag, $content, $eliminateExtraEndTags =
false)
53 $tags = array_unique(GeneralUtility::trimExplode(
',', $tag,
true));
54 array_walk($tags,
function (&$tag) {
55 $tag = preg_quote($tag,
'/');
57 $regexStr =
'/\\<\\/?(' . implode(
'|', $tags) .
')(\\s*\\>|\\s[^\\>]*\\>)/si';
58 $parts = preg_split($regexStr, $content);
60 $pointer = strlen($parts[0]);
65 $partsSliced = array_slice($parts, 1,
null,
true);
66 foreach ($partsSliced as $v) {
67 $isEndTag = substr($content, $pointer, 2) ===
'</';
68 $tagLen = strcspn(substr($content, $pointer),
'>') + 1;
74 $newParts[] = $buffer;
80 $mbuffer = substr($content, $pointer, strlen($v) + $tagLen);
81 $pointer += strlen($mbuffer);
88 if ($eliminateExtraEndTags && $nested < 0) {
93 $buffer .= substr($content, $pointer, $tagLen);
97 if (!$nested && !$eliminated) {
98 $newParts[] = $buffer;
102 $mbuffer = substr($content, $pointer, strlen($v));
103 $pointer += strlen($mbuffer);
107 $newParts[] = $buffer;
126 foreach ($parts as $k => $v) {
131 $tagsArray[
'tag_end'] =
'</' . $firstTagName .
'>';
132 $tagsArray[
'tag_name'] = strtolower($firstTagName);
135 $tagsArray = $procObj->{$callBackTags}($tagsArray, $level);
137 $parts[$k] = $tagsArray[
'tag_start'] . $tagsArray[
'content'] . $tagsArray[
'tag_end'];
139 if ($callBackContent) {
140 $parts[$k] = $procObj->{$callBackContent}($parts[$k], $level);
144 return implode(
'', $parts);
157 public function splitTags($tag, $content)
159 $tags = GeneralUtility::trimExplode(
',', $tag,
true);
160 array_walk($tags,
function (&$tag) {
161 $tag = preg_quote($tag,
'/');
163 $regexStr =
'/\\<(' . implode(
'|', $tags) .
')(\\s[^>]*)?\\/?>/si';
164 $parts = preg_split($regexStr, $content);
165 $pointer = strlen($parts[0]);
167 $newParts[] = $parts[0];
170 $partsSliced = array_slice($parts, 1,
null,
true);
171 foreach ($partsSliced as $v) {
172 $tagLen = strcspn(substr($content, $pointer),
'>') + 1;
175 $tag = substr($content, $pointer, $tagLen);
177 $pointer += strlen($tag);
180 $pointer += strlen($v);
192 public function removeFirstAndLastTag($str)
194 $parser = SimpleParser::fromString($str);
195 $first =
$parser->getFirstNode(SimpleNode::TYPE_ELEMENT);
196 $last =
$parser->getLastNode(SimpleNode::TYPE_ELEMENT);
197 if ($first ===
null || $first === $last) {
200 $sequence = array_slice(
202 $first->getIndex() + 1,
203 $last->getIndex() - $first->getIndex() - 1
205 return implode(
'', array_map(
'strval', $sequence));
215 public function getFirstTag($str)
217 $parser = SimpleParser::fromString($str);
218 $first =
$parser->getFirstNode(SimpleNode::TYPE_ELEMENT);
219 if ($first ===
null) {
222 $sequence = array_slice(
225 $first->getIndex() + 1
227 return implode(
'', array_map(
'strval', $sequence));
238 public function getFirstTagName($str, $preserveCase =
false)
240 $parser = SimpleParser::fromString($str);
241 $elements =
$parser->getNodes(SimpleNode::TYPE_ELEMENT);
242 foreach ($elements as $element) {
243 $name = $element->getElementName();
244 if ($name ===
null) {
247 return $preserveCase ? $name : strtoupper($name);
264 public function get_tag_attributes($tag, $deHSC =
false)
266 list($components, $metaC) = $this->split_tag_attributes($tag);
271 $attributesMeta = [];
272 if (is_array($components)) {
273 foreach ($components as $key => $val) {
278 $attributes[$name] = $deHSC ? htmlspecialchars_decode($val) : $val;
279 $attributesMeta[$name][
'dashType'] = $metaC[$key];
283 if ($namekey = preg_replace(
'/[^[:alnum:]_\\:\\-]/',
'', $val)) {
284 $name = strtolower($namekey);
285 $attributesMeta[$name] = [];
286 $attributesMeta[$name][
'origTag'] = $namekey;
287 $attributes[$name] =
'';
295 return [$attributes, $attributesMeta];
313 public function split_tag_attributes($tag)
316 if (preg_match(
'/(\\<[^\\s]+\\s+)?(.*?)\\s*(\\>)?$/s', $tag, $matches) !== 1) {
319 $tag_tmp = $matches[2];
323 if (preg_match_all(
'/("[^"]*"|\'[^\']*\'|[^\\s"\'\\=]+|\\=)/s', $tag_tmp, $matches) > 0) {
324 foreach ($matches[1] as $part) {
325 $firstChar = $part[0];
326 if ($firstChar ===
'"' || $firstChar ===
'\'') {
327 $metaValue[] = $firstChar;
328 $value[] = substr($part, 1, -1);
335 return [$value, $metaValue];
379 public function HTMLcleaner($content, $tags = [], $keepAll = 0, $hSC = 0, $addConfig = [])
382 $tokArr = explode(
'<', $content);
383 $newContent[] = $this->bidir_htmlspecialchars(current($tokArr), $hSC);
385 $tokArrSliced = array_slice($tokArr, 1,
null,
true);
392 foreach ($tokArrSliced as $tok) {
394 if (($eocPos = strpos($tok,
'-->')) ===
false) {
396 $newContent[$c++] =
'<' . $tok;
400 $newContent[$c++] =
'<' . substr($tok, 0, $eocPos + 3);
401 $tok = substr($tok, $eocPos + 3);
404 } elseif ($inCdata) {
405 if (($eocPos = strpos($tok,
'/*]]>*/')) ===
false) {
407 $newContent[$c++] =
'<' . $tok;
411 $newContent[$c++] =
'<' . substr($tok, 0, $eocPos + 10);
412 $tok = substr($tok, $eocPos + 10);
415 } elseif (strpos($tok,
'!--') === 0) {
416 if (($eocPos = strpos($tok,
'-->')) ===
false) {
418 $newContent[$c++] =
'<' . $tok;
423 $newContent[$c++] =
'<' . substr($tok, 0, $eocPos + 3);
424 $tok = substr($tok, $eocPos + 3);
426 } elseif (strpos($tok,
'![CDATA[*/') === 0) {
427 if (($eocPos = strpos($tok,
'/*]]>*/')) ===
false) {
429 $newContent[$c++] =
'<' . $tok;
434 $newContent[$c++] =
'<' . substr($tok, 0, $eocPos + 10);
435 $tok = substr($tok, $eocPos + 10);
438 $firstChar = $tok[0] ??
null;
440 if (!$skipTag && preg_match(
'/[[:alnum:]\\/]/', $firstChar) === 1) {
441 $tagEnd = strpos($tok,
'>');
444 $endTag = $firstChar ===
'/' ? 1 : 0;
445 $tagContent = substr($tok, $endTag, $tagEnd - $endTag);
446 $tagParts = preg_split(
'/\\s+/s', $tagContent, 2);
447 $tagName = strtolower($tagParts[0]);
449 if (isset($tags[$tagName])) {
451 if (is_array($tags[$tagName])) {
452 if (preg_match(
'/^(' . self::VOID_ELEMENTS .
' )$/i', $tagName)) {
458 if (isset($tags[$tagName][
'overrideAttribs']) && (
string)$tags[$tagName][
'overrideAttribs'] !==
'') {
459 $tagParts[1] = $tags[$tagName][
'overrideAttribs'];
462 if (isset($tags[$tagName][
'allowedAttribs']) && (
string)$tags[$tagName][
'allowedAttribs'] !==
'') {
464 if ((
string)$tags[$tagName][
'allowedAttribs'] ===
'0') {
466 } elseif (isset($tagParts[1]) && trim($tagParts[1])) {
467 $tagAttrib = $this->get_tag_attributes($tagParts[1]);
471 $tags[$tagName][
'_allowedAttribs']
472 ?? GeneralUtility::trimExplode(
',', strtolower($tags[$tagName][
'allowedAttribs']),
true)
474 foreach ($tList as $allowTag) {
475 if (isset($tagAttrib[0][$allowTag])) {
476 $newTagAttrib[$allowTag] = $tagAttrib[0][$allowTag];
480 $tagParts[1] = $this->compileTagAttribs($newTagAttrib, $tagAttrib[1]);
484 if (isset($tags[$tagName][
'fixAttrib']) && is_array($tags[$tagName][
'fixAttrib'])) {
485 $tagAttrib = $this->get_tag_attributes($tagParts[1]);
487 foreach ($tags[$tagName][
'fixAttrib'] as $attr => $params) {
488 if (isset($params[
'set']) && $params[
'set'] !==
'') {
489 $tagAttrib[0][$attr] = $params[
'set'];
491 if (!empty($params[
'unset'])) {
492 unset($tagAttrib[0][$attr]);
494 if (!empty($params[
'default']) && !isset($tagAttrib[0][$attr])) {
495 $tagAttrib[0][$attr] = $params[
'default'];
497 if ($params[
'always'] || isset($tagAttrib[0][$attr])) {
498 if ($params[
'trim']) {
499 $tagAttrib[0][$attr] = trim($tagAttrib[0][$attr]);
501 if ($params[
'intval']) {
502 $tagAttrib[0][$attr] = (int)$tagAttrib[0][$attr];
504 if ($params[
'lower']) {
505 $tagAttrib[0][$attr] = strtolower($tagAttrib[0][$attr]);
507 if ($params[
'upper']) {
508 $tagAttrib[0][$attr] = strtoupper($tagAttrib[0][$attr]);
510 if ($params[
'range']) {
511 if (isset($params[
'range'][1])) {
512 $tagAttrib[0][$attr] = MathUtility::forceIntegerInRange($tagAttrib[0][$attr], (
int)$params[
'range'][0], (
int)$params[
'range'][1]);
514 $tagAttrib[0][$attr] = MathUtility::forceIntegerInRange($tagAttrib[0][$attr], (
int)$params[
'range'][0]);
517 if (isset($params[
'list']) && is_array($params[
'list'])) {
520 if ($attr ===
'class') {
522 $classes = GeneralUtility::trimExplode(
' ', $tagAttrib[0][$attr],
true);
523 foreach ($classes as $class) {
524 if (in_array($class, $params[
'list'])) {
525 $newClasses[] = $class;
528 if (!empty($newClasses)) {
529 $tagAttrib[0][$attr] = implode(
' ', $newClasses);
531 $tagAttrib[0][$attr] = $params[
'list'][0];
534 if (!in_array($this->caseShift($tagAttrib[0][$attr], $params[
'casesensitiveComp']), $this->caseShift($params[
'list'], $params[
'casesensitiveComp'], $tagName))) {
535 $tagAttrib[0][$attr] = $params[
'list'][0];
539 if ($params[
'removeIfFalse'] && $params[
'removeIfFalse'] !==
'blank' && !$tagAttrib[0][$attr] || $params[
'removeIfFalse'] ===
'blank' && (
string)$tagAttrib[0][$attr] ===
'') {
540 unset($tagAttrib[0][$attr]);
542 if ((
string)$params[
'removeIfEquals'] !==
'' && $this->caseShift($tagAttrib[0][$attr], $params[
'casesensitiveComp']) === $this->caseShift($params[
'removeIfEquals'], $params[
'casesensitiveComp'])) {
543 unset($tagAttrib[0][$attr]);
545 if ($params[
'prefixLocalAnchors']) {
546 if ($tagAttrib[0][$attr][0] ===
'#') {
547 if ($params[
'prefixLocalAnchors'] == 2) {
549 $contentObjectRenderer = GeneralUtility::makeInstance(ContentObjectRenderer::class);
550 $prefix = $contentObjectRenderer->getUrlToCurrentLocation();
552 $prefix = GeneralUtility::getIndpEnv(
'TYPO3_REQUEST_URL');
554 $tagAttrib[0][$attr] = $prefix . $tagAttrib[0][$attr];
557 if ($params[
'prefixRelPathWith']) {
558 $urlParts = parse_url($tagAttrib[0][$attr]);
559 if (!$urlParts[
'scheme'] && $urlParts[
'path'][0] !==
'/') {
561 $tagAttrib[0][$attr] = $params[
'prefixRelPathWith'] . $tagAttrib[0][$attr];
564 if ($params[
'userFunc']) {
565 if (is_array($params[
'userFunc.'])) {
566 $params[
'userFunc.'][
'attributeValue'] = $tagAttrib[0][$attr];
568 $params[
'userFunc.'] = $tagAttrib[0][$attr];
570 $tagAttrib[0][$attr] = GeneralUtility::callUserFunction($params[
'userFunc'], $params[
'userFunc.'], $this);
574 $tagParts[1] = $this->compileTagAttribs($tagAttrib[0], $tagAttrib[1]);
581 if (!empty($tags[$tagName][
'protect'])) {
589 if (!empty($tags[$tagName][
'remap'])) {
590 $tagParts[0] = $tags[$tagName][
'remap'];
593 if ($endTag || empty($tags[$tagName][
'rmTagIfNoAttrib']) || trim($tagParts[1] ??
'')) {
596 if ($endTag && isset($tags[$tagName][
'allowedAttribs']) && $tags[$tagName][
'allowedAttribs'] === 0 && $tags[$tagName][
'rmTagIfNoAttrib'] === 1) {
599 if (isset($tags[$tagName][
'nesting'])) {
600 if (!isset($tagRegister[$tagName])) {
601 $tagRegister[$tagName] = [];
605 if ($tags[$tagName][
'nesting'] ===
'global') {
606 $lastEl = end($tagStack);
607 if ($tagName !== $lastEl) {
608 if (in_array($tagName, $tagStack,
true)) {
609 while (!empty($tagStack) && $tagName !== $lastEl) {
610 $elPos = end($tagRegister[$lastEl]);
611 unset($newContent[$elPos]);
612 array_pop($tagRegister[$lastEl]);
613 array_pop($tagStack);
614 $lastEl = end($tagStack);
622 if (empty($tagRegister[$tagName]) || !$correctTag) {
625 array_pop($tagRegister[$tagName]);
626 if ($tags[$tagName][
'nesting'] ===
'global') {
627 array_pop($tagStack);
631 $tagRegister[$tagName][] = $c;
632 if ($tags[$tagName][
'nesting'] ===
'global') {
633 $tagStack[] = $tagName;
639 $newContent[$c++] = $lt . ($endTag ?
'/' :
'') . trim($tagParts[0] .
' ' . ($tagParts[1] ??
'')) . ($emptyTag ?
' /' :
'') . $gt;
643 $newContent[$c++] =
'<' . ($endTag ?
'/' :
'') . $tagContent .
'>';
645 } elseif ($keepAll) {
647 if ($keepAll ===
'protect') {
654 $newContent[$c++] = $lt . ($endTag ?
'/' :
'') . $tagContent . $gt;
656 $newContent[$c++] = $this->bidir_htmlspecialchars(substr($tok, $tagEnd + 1), $hSC);
658 $newContent[$c++] = $this->bidir_htmlspecialchars(
'<' . $tok, $hSC);
661 $newContent[$c++] = $this->bidir_htmlspecialchars(($skipTag ?
'' :
'<') . $tok, $hSC);
667 foreach ($tagRegister as $tag => $positions) {
668 foreach ($positions as $pKey) {
669 unset($newContent[$pKey]);
672 $newContent = implode(
'', $newContent);
673 $newContent = $this->stripEmptyTagsIfConfigured($newContent, $addConfig);
684 public function bidir_htmlspecialchars($value,
$dir)
686 switch ((
int)
$dir) {
688 return htmlspecialchars($value);
690 return htmlspecialchars($value, ENT_COMPAT,
'UTF-8',
false);
692 return htmlspecialchars_decode($value);
707 public function prefixResourcePath($main_prefix, $content, $alternatives = [], $suffix =
'')
709 $parts = $this->splitTags(
'embed,td,table,body,img,input,form,link,script,a,param', $content);
710 foreach ($parts as $k => $v) {
712 $params = $this->get_tag_attributes($v);
714 $tagEnd = substr($v, -2) ===
'/>' ?
' />' :
'>';
716 $firstTagName = $this->getFirstTagName($v);
718 $prefix = $alternatives[strtoupper($firstTagName)] ?? $main_prefix;
719 switch (strtolower($firstTagName)) {
725 $src = $params[0][
'background'];
727 $params[0][
'background'] = $this->prefixRelPath($prefix, $params[0][
'background'], $suffix);
738 $src = $params[0][
'src'];
740 $params[0][
'src'] = $this->prefixRelPath($prefix, $params[0][
'src'], $suffix);
747 $src = $params[0][
'href'];
749 $params[0][
'href'] = $this->prefixRelPath($prefix, $params[0][
'href'], $suffix);
754 $src = $params[0][
'action'];
756 $params[0][
'action'] = $this->prefixRelPath($prefix, $params[0][
'action'], $suffix);
761 $test = $params[0][
'name'];
762 if ($test && $test ===
'movie') {
763 if ($params[0][
'value']) {
764 $params[0][
'value'] = $this->prefixRelPath($prefix, $params[0][
'value'], $suffix);
770 if ($somethingDone) {
771 $tagParts = preg_split(
'/\\s+/s', $v, 2);
772 $tagParts[1] = $this->compileTagAttribs($params[0], $params[1]);
773 $parts[$k] =
'<' . trim(strtolower($firstTagName) .
' ' . $tagParts[1]) . $tagEnd;
777 $content = implode(
'', $parts);
779 $prefix = $alternatives[
'style'] ?? $main_prefix;
780 if ((
string)$prefix !==
'') {
781 $parts = $this->splitIntoBlock(
'style', $content);
782 foreach ($parts as $k => &$part) {
784 $part = preg_replace(
'/(url[[:space:]]*\\([[:space:]]*["\']?)([^"\')]*)(["\']?[[:space:]]*\\))/i',
'\\1' . $prefix .
'\\2' . $suffix .
'\\3', $part);
788 $content = implode(
'', $parts);
802 public function prefixRelPath($prefix, $srcVal, $suffix =
'')
806 if ($srcVal[0] !==
'/' && $srcVal[0] !==
'#') {
807 $urlParts = parse_url($srcVal);
809 if (!$urlParts[
'scheme']) {
810 $srcVal = $prefix . $srcVal . $suffix;
825 public function caseShift($str, $caseSensitiveComparison, $cacheKey =
'')
827 if ($caseSensitiveComparison) {
830 if (is_array($str)) {
832 if ($cacheKey && isset($this->caseShift_cache[$cacheKey])) {
833 $str = $this->caseShift_cache[$cacheKey];
835 array_walk($str,
function (&$value) {
836 $value = strtoupper($value);
839 $this->caseShift_cache[$cacheKey] = $str;
843 $str = strtoupper($str);
856 public function compileTagAttribs($tagAttrib, $meta = [])
859 foreach ($tagAttrib as $k => $v) {
860 $attr = $meta[$k][
'origTag'] ?: $k;
861 if (strcmp($v,
'') || isset($meta[$k][
'dashType'])) {
862 $dash = $meta[$k][
'dashType'] ?: (MathUtility::canBeInterpretedAsInteger($v) ?
'' :
'"');
863 $attr .=
'=' . $dash . $v . $dash;
867 return implode(
' ', $accu);
878 public function HTMLparserConfig($TSconfig, $keepTags = [])
881 $alTags = array_flip(GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'allowTags'] ??
''),
true));
882 $keepTags = array_merge($alTags, $keepTags);
884 if (isset($TSconfig[
'tags.']) && is_array($TSconfig[
'tags.'])) {
885 foreach ($TSconfig[
'tags.'] as $key => $tagC) {
886 if (!is_array($tagC) && $key == strtolower($key)) {
887 if ((
string)$tagC ===
'0') {
888 unset($keepTags[$key]);
890 if ((
string)$tagC ===
'1' && !isset($keepTags[$key])) {
895 foreach ($TSconfig[
'tags.'] as $key => $tagC) {
896 if (is_array($tagC) && $key == strtolower($key)) {
897 $key = substr($key, 0, -1);
898 if (!is_array($keepTags[$key])) {
899 $keepTags[$key] = [];
901 if (isset($tagC[
'fixAttrib.']) && is_array($tagC[
'fixAttrib.'])) {
902 foreach ($tagC[
'fixAttrib.'] as $atName => $atConfig) {
903 if (is_array($atConfig)) {
904 $atName = substr($atName, 0, -1);
905 if (!is_array($keepTags[$key][
'fixAttrib'][$atName])) {
906 $keepTags[$key][
'fixAttrib'][$atName] = [];
908 $keepTags[$key][
'fixAttrib'][$atName] = array_merge($keepTags[$key][
'fixAttrib'][$atName], $atConfig);
909 if ((
string)$keepTags[$key][
'fixAttrib'][$atName][
'range'] !==
'') {
910 $keepTags[$key][
'fixAttrib'][$atName][
'range'] = GeneralUtility::trimExplode(
',', $keepTags[$key][
'fixAttrib'][$atName][
'range']);
912 if ((
string)$keepTags[$key][
'fixAttrib'][$atName][
'list'] !==
'') {
913 $keepTags[$key][
'fixAttrib'][$atName][
'list'] = GeneralUtility::trimExplode(
',', $keepTags[$key][
'fixAttrib'][$atName][
'list']);
918 unset($tagC[
'fixAttrib.'], $tagC[
'fixAttrib']);
919 if (!empty($tagC[
'rmTagIfNoAttrib']) && empty($tagC[
'nesting'])) {
920 $tagC[
'nesting'] = 1;
922 $keepTags[$key] = array_merge($keepTags[$key], $tagC);
927 if (!empty($TSconfig[
'localNesting'])) {
928 $lN = GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'localNesting']),
true);
929 foreach ($lN as $tn) {
930 if (isset($keepTags[$tn])) {
931 if (!is_array($keepTags[$tn])) {
934 $keepTags[$tn][
'nesting'] = 1;
938 if (!empty($TSconfig[
'globalNesting'])) {
939 $lN = GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'globalNesting']),
true);
940 foreach ($lN as $tn) {
941 if (isset($keepTags[$tn])) {
942 if (!is_array($keepTags[$tn])) {
945 $keepTags[$tn][
'nesting'] =
'global';
949 if (!empty($TSconfig[
'rmTagIfNoAttrib'])) {
950 $lN = GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'rmTagIfNoAttrib']),
true);
951 foreach ($lN as $tn) {
952 if (isset($keepTags[$tn])) {
953 if (!is_array($keepTags[$tn])) {
956 $keepTags[$tn][
'rmTagIfNoAttrib'] = 1;
957 if (empty($keepTags[$tn][
'nesting'])) {
958 $keepTags[$tn][
'nesting'] = 1;
963 if (!empty($TSconfig[
'noAttrib'])) {
964 $lN = GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'noAttrib']),
true);
965 foreach ($lN as $tn) {
966 if (isset($keepTags[$tn])) {
967 if (!is_array($keepTags[$tn])) {
970 $keepTags[$tn][
'allowedAttribs'] = 0;
974 if (!empty($TSconfig[
'removeTags'])) {
975 $lN = GeneralUtility::trimExplode(
',', strtolower($TSconfig[
'removeTags']),
true);
976 foreach ($lN as $tn) {
978 $keepTags[$tn][
'allowedAttribs'] = 0;
979 $keepTags[$tn][
'rmTagIfNoAttrib'] = 1;
984 if (isset($TSconfig[
'stripEmptyTags'])) {
985 $addConfig[
'stripEmptyTags'] = $TSconfig[
'stripEmptyTags'];
986 if (isset($TSconfig[
'stripEmptyTags.'])) {
987 $addConfig[
'stripEmptyTags.'] = $TSconfig[
'stripEmptyTags.'];
992 '' . ($TSconfig[
'keepNonMatchedTags'] ??
''),
993 (
int)($TSconfig[
'htmlSpecialChars'] ?? 0),
1008 public function stripEmptyTags($content, $tagList =
'', $treatNonBreakingSpaceAsEmpty =
false, $keepTags =
false)
1010 if (!empty($tagList)) {
1011 $tagRegEx = implode(
'|', GeneralUtility::trimExplode(
',', $tagList,
true));
1013 $tagRegEx =
'(?!' . $tagRegEx .
')[^ >]+';
1016 $tagRegEx =
'[^ >]+';
1019 $nbspRegex = $treatNonBreakingSpaceAsEmpty ?
'|( )' :
'';
1020 $finalRegex = sprintf(
'/<(%s)[^>]*>( %s)*<\/\\1[^>]*>/i', $tagRegEx, $nbspRegex);
1021 while ($count !== 0) {
1022 $content = preg_replace($finalRegex,
'', $content, -1, $count);
1034 protected function stripEmptyTagsIfConfigured($value, $configuration)
1036 if (empty($configuration[
'stripEmptyTags'])) {
1042 if (!empty($configuration[
'stripEmptyTags.'][
'keepTags'])) {
1043 $tags = $configuration[
'stripEmptyTags.'][
'keepTags'];
1045 } elseif (!empty($configuration[
'stripEmptyTags.'][
'tags'])) {
1046 $tags = $configuration[
'stripEmptyTags.'][
'tags'];
1049 $treatNonBreakingSpaceAsEmpty = !empty($configuration[
'stripEmptyTags.'][
'treatNonBreakingSpaceAsEmpty']);
1051 return $this->stripEmptyTags($value, $tags, $treatNonBreakingSpaceAsEmpty, $keepTags);