Returns a message indicating what tags are allowed.

@param string $badtag The disallowed tag that was supplied
@return string Message indicating what tags are allowed
190962
private function allowed_tags_message($badtag) {
        $a = new stdClass();
        $a->tag = htmlspecialchars($badtag);
        $a->allowed = $this->get_list_of_printable_allowed_tags($this->allowedhtmltags);
        if ($a->allowed) {
            return get_string('tagsnotallowed', 'qtype_gapselect', $a);
        } else {
            return get_string('tagsnotallowedatall', 'qtype_gapselect', $a);
        }
    }
494845
public static function inappropriate_tags( $reset = false ) {
		if ( empty( self::$inappropriate_tags ) || $reset ) {
			self::$inappropriate_tags = \array_flip(
				\array_merge(
					\array_filter(
						\array_keys( Elements::$html5 ),
						function( $tag ) {
							return Elements::isA( $tag, Elements::VOID_TAG )
								|| Elements::isA( $tag, Elements::TEXT_RAW )
								|| Elements::isA( $tag, Elements::TEXT_RCDATA );
						}
					),
					self::ADDITIONAL_INAPPROPRIATE_TAGS
				)
			);
		}

		return self::$inappropriate_tags;
	}
39248
private function tag($tags)
    {
        $this->initialize();

        if (!is_array($tags)) {
            $tags = [$tags];
        }
        foreach ($tags as $tag) {
            if (!is_string($tag)) {
                throw new InvalidArgumentException(sprintf('Cache tag must be string, "%s" given', is_object($tag) ? get_class($tag) : gettype($tag)));
            }
            if (isset($this->tags[$tag])) {
                continue;
            }
            if (!isset($tag[0])) {
                throw new InvalidArgumentException('Cache tag length must be greater than zero');
            }
            if (isset($tag[strcspn($tag, '{}()/\@:')])) {
                throw new InvalidArgumentException(sprintf('Cache tag "%s" contains reserved characters {}()/\@:', $tag));
            }
            $this->tags[$tag] = $tag;
        }

        return $this;
    }
408703
public static function strip($text = '', array $allowedTags = []): string
    {
        $text = \htmlspecialchars_decode((string)$text, ENT_COMPAT | ENT_HTML5);
        foreach ($allowedTags as $tag) {
            $text = \preg_replace('|<(/?'.$tag.'\ ?/?)>|i', '{{{{\\1}}}}', $text);
            $text = \preg_replace('|<('.$tag.' [^>]+)>|i', '{{{{\\1}}}}', $text);
        }
        $text = \preg_replace('/<[^>]+>/', ' ', $text);
        foreach ($allowedTags as $tag) {
            $text = \preg_replace('|{{{{(/?'.$tag.'\ ?/?)}}}}|i', '<\\1>', $text);
            $text = \preg_replace('|{{{{('.$tag.' [^}]+)}}}}|i', '<\\1>', $text);
        }
        $text = \preg_replace('/\s+/', ' ', $text);

        return \trim($text);
    }
582747
private function _mangleTags($tags)
    {
        foreach ($tags as $i => $tag) {
            $tags[$i] = $this->_mangleTag($tag);
        }
        return $tags;
    }
1281028
private static function sanitizeTag($tag, $allowed = null, $resetStack = false)
    {
        static $stack = [];
        if ($resetStack) {
            $ret = $stack;
            $stack = [];
            return $ret;
        }

        $tag = substr($tag, 1, -1); // strip off leading '<' and trailing '>'
        if ($tag[0] == '/') {
            preg_match('/^\w+/', substr($tag, 1), $m);
            $closingTag = strtolower($m[0]);
            $localStack = [];

            if (null !== $allowed
                && (is_array($allowed) && !array_key_exists($closingTag, $allowed))
                || (is_callable($allowed) && !call_user_func($allowed, $closingTag))
            ) {
                return '<!-- ' . htmlspecialchars($tag) . ' -->';
            }

            do {
                if (!count($stack)) {
                    $stack = array_reverse($localStack);
                    // tag was never opened. Drop closing tag
                    return '';
                }
                $top = array_pop($stack);
                $localStack[] = $top;
            } while (strtolower($top) != $closingTag);
            $ret = '';
            foreach ($localStack as $needClose) {
                $ret .= '</' . $needClose . '>';
            }

            return $ret;
        } else {
            $ret = '';
            $attributes = [];
            preg_match('/^[\w-:]+/', $tag, $m);
            $tagName = strtolower($m[0]);
            if (null !== $allowed
                && (is_array($allowed) && !array_key_exists($tagName, $allowed))
                || (is_callable($allowed) && !call_user_func($allowed, $tagName))
            ) {
                return '<!-- ' . htmlspecialchars($tag) . ' -->';
            }

            $paragraphLevelElements = ['p', 'h6', 'h5', 'h4', 'h3', 'h2', 'h1', 'table', 'ul', 'div'];
            $inlineElements = ['span', 'b', 'i', 'u', 'span', 'strong', 'em', 'a', 'sup', 'sub'];
            $selfClosingElements = ['li', 'td', 'th', 'tr'];
            $forcedParents = ['li' => ['ul', 'ol']];

            if (count($stack) && in_array($tagName, $paragraphLevelElements)) {
                while (in_array(end($stack), array_merge($paragraphLevelElements, $inlineElements))) {
                    $ret .= '</' . array_pop($stack) . '>';
                }
            }
            if (count($stack) && in_array($tagName, $selfClosingElements)) {
                while (in_array(end($stack), $inlineElements)) {
                    $ret .= '</' . array_pop($stack) . '>';
                }
                if (end($stack) === $tagName) {
                    $ret .= '</' . array_pop($stack) . '>';
                }
            }

            if (array_key_exists($tagName, $forcedParents) && !in_array(end($stack), $forcedParents[$tagName])) {
                // if the parent would close paragraph or inline elements, do it now.
                if (count($stack) && in_array($forcedParents[$tagName][0], $paragraphLevelElements)) {
                    while (in_array(end($stack), array_merge($paragraphLevelElements, $inlineElements))) {
                        $ret .= '</' . array_pop($stack) . '>';
                    }
                }
                $ret .= '<' . $forcedParents[$tagName][0] . '>';
                $stack[] = $forcedParents[$tagName][0];
            }

            if (substr($tag, -1) == '/') {
                $isEmpty = true;
            } else {
                $isEmpty = in_array($tagName, ['br', 'img', 'input', 'param', 'isindex', 'area']);
            }
            for ($i = strlen($m[0]); $i < strlen($tag); true) {
                $preI = $i;

                $chunk = substr($tag, $i);

                if (preg_match('/^([\w-]+)\s*=\s*\"([^"]*)\"?/', $chunk, $m)) {
                    $attributes[$m[1]] = $m[2];
                    $i += strlen($m[0]);
                } elseif (preg_match('/^([\w-]+)\s*=\s*\'([^\']*)\'?/', $chunk, $m)) {
                    $attributes[$m[1]] = $m[2];
                    $i += strlen($m[0]);
                } elseif (preg_match('/^([\w-]+)=(\S+)/', $chunk, $m)) {
                    $attributes[$m[1]] = $m[2];
                    $i += strlen($m[0]);
                } elseif (preg_match('/^(\w+)/', $chunk, $m)) {
                    $attributes[$m[1]] = $m[1];
                    $i += strlen($m[0]);
                } else {
                    // drop character
                    $i++;
                }
                assert($i != $preI);
            }

            $ret .= '<';
            $ret .= $tagName;
            if (count($attributes)) {
                foreach ($attributes as $attrName => $value) {
                    $callback = null;
                    if (is_callable($allowed)) {
                        $callback = $allowed;
                    } elseif (is_array($allowed) && isset($allowed[$tagName]) && is_callable($allowed[$tagName])) {
                        $callback = $allowed[$tagName];
                    } elseif (is_array($allowed[$tagName]) && isset($allowed[$tagName][$attrName])) {
                        $callback = $allowed[$tagName][$attrName];
                    }
                    if (null !== $callback) {
                        $value = call_user_func($callback, $tagName, $attrName, $value);
                    }
                    if (false === $value) {
                        continue;
                    }
                    if (!preg_match('/^[a-z_-]/', $attrName)) {
                        // drop malformed attribute name
                        continue;
                    }
                    $ret .= ' ';
                    $ret .= sprintf('%s="%s"', $attrName, str_replace('"', '&quot;', $value));
                }
            }
            if ($isEmpty) {
                $ret .= ' /';
            } else {
                $stack[] = $tagName;
            }
            $ret .= '>';
            return $ret;
        }
    }
1189766
public function getSubnodesByTag($tag)
    {
        return $this
            ->getSubnodes()
            ->filter(function (\Elcodi\Component\Menu\Entity\Menu\Interfaces\NodeInterface $menuNode) use ($tag) {

                return $menuNode->getTag() == $tag;
            });
    }
1224656
private function tag_has_type(string $tag){
    return in_array('type', array_values(
      \is_array($this->tags[$tag]) ?
        $this->tags[$tag] :
        $this->tags[$this->tags[$tag]]
    ));
  }
1166908
protected function _getTagsAsString()
    {
        if (empty($this->_properties['tags'])) {
            return null;
        }

        return implode(', ', collection($this->_properties['tags'])->extract('tag')->toList());
    }
523460
public function removeTag($tag)
    {
        if (is_array($tag))
        {
            foreach ($tag as $t)
            {
                if (isset($this->allowed_tags[$t]))
                    unset($this->allowed_tags[$t]);
                $this->remove_tags[$t] = true;
            }
        }
        else
        {
            if (isset($this->allowed_tags[$tag]))
                unset($this->allowed_tags[$tag]);
            $this->remove_tags[$tag] = true;
        }
        return $this;
    }
522229
public function getTagValue($tag)
	{
		if(!$this->hasTag($tag))
		{
			throw new \OutOfBoundsException('Tag ' . $tag . ' is not set');
		}
		
		if(empty($this->tags[$tag]))
		{
			throw new \OutOfBoundsException('Tag ' . $tag . ' does not have a value');
		}
		
		return $this->tags[$tag][0];
	}
896918
public function filter($text, $allowed_tags = null, $allowed_protocols = null)
    {
        $settings = $this->module->getSettings('xss');

        if (!isset($allowed_tags)) {
            $allowed_tags = $settings['tags'];
        }

        if (!isset($allowed_protocols)) {
            $allowed_protocols = $settings['protocols'];
        }

        return $this->getFilter()
            ->setTags($allowed_tags)
            ->setProtocols($allowed_protocols)
            ->filter($text);
    }
141600
public function tags($tag)
    {
        return $this->model->where('is_published', 1)
            ->where('published_at', '<=', Carbon::now(config('app.timezone'))->format('Y-m-d H:i:s'))
            ->where('tags', 'LIKE', '%'.$tag.'%')->orderBy('created_at', 'desc')
            ->paginate(config('cms.pagination', 24));
    }
714651
public function closeTag($tag)
    {
        if (!in_array($tag, $this->voidTags)) {
            return replace_variables($this->closeTagPattern, compact('tag'));
        }

        return '';
    }
505320
public function asText(StringLength $length = null, array $allowedTags = [])
    {
        return $this->handleFilter(
                function() use($length, $allowedTags)
                {
                    $textFilter = new filter\TextFilter();
                    return filter\RangeFilter::wrap(
                            $textFilter->allowTags($allowedTags),
                            $length
                    );
                }
        );
    }
298660
public function renderTag($tag)
    {
        $str = "<".$tag["tag"];
        foreach ($tag["options"] as $key=>$value) {
            $str.=" $key='$value'";
        }
        $str.=">".$tag["content"]."</".$tag["tag"].">";
        return $str;
    }
85611
public static function encode($tag) {
    if (strpos($tag, ',') !== FALSE || strpos($tag, '"') !== FALSE) {
      return '"' . str_replace('"', '""', $tag) . '"';
    }
    return $tag;
  }