Purifies the HTML content by removing malicious code.
@param mixed $content the content to be purified.
@return mixed the purified content
4853
public function purify($content)
	{
		if(is_array($content))
			$content=array_map(array($this,'purify'),$content);
		else
			$content=$this->getPurifier()->purify($content);
		return $content;
	}
108922
public function transform($content)
    {
        if (!trim($content)) {
            return '';
        }

        $crawler = new Crawler();
        $crawler->addHtmlContent($content);

        $crawler->filter('img')->each(
            function (Crawler $node) {
                $image = $node->getNode(0);
                if ($image->hasAttribute('data-src')) {
                    $src = $image->getAttribute('data-src');
                    $image->setAttribute('src', $src);
                    $image->removeAttribute('data-src');
                }
            }
        );

        try {
            return $crawler->html();
        } catch (\InvalidArgumentException $exception) {
            return $content;
        }
    }
227160
public function extract($content)
    {
        $pattern = $this->getRegex();

        preg_match_all("/$pattern/s", $content, $matches);

        $objects = [];

        foreach ($matches as $key => $match) {
            $name = null;

            if ($key == 0) {
                $name = 'original';
            } elseif ($key == 2) {
                $name = 'name';
            } elseif ($key == 3) {
                $name = 'attributes';
            } elseif ($key == 5) {
                $name = 'content';
            }

            if (!is_null($name)) {
                foreach ($match as $k => $v) {
                    if (!isset($objects[$k])) {
                        $objects[$k] = [];
                    }

                    if ($name == 'attributes') {
                        $attributes = $this->parseAttr($v);

                        if (!is_array($attributes)) {
                            $attributes = [];
                        }

                        $objects[$k][$name] = $attributes;
                    } elseif ($name == 'content') {
                        if ($this->hasShortcode($v)) {
                            $objects[$k][$name] = $this->extract($v);
                        } else {
                            $objects[$k][$name] = $v;
                        }
                    } else {
                        $objects[$k][$name] = $v;
                    }
                }
            }
        }

        return $objects;
    }
367077
public function decode_content($content) {
        if (!$content = $this->precheck_content($content)) { // Perform some prechecks
            return false;
        }
        // Iterate over all rules, chaining results
        foreach ($this->rules as $rule) {
            $content = $rule->decode($content);
        }
        return $content;
    }
1349698
public static function bb(&$content)
    {
        $content = preg_replace(array_flip(self::$_bbs), self::$_bbs, $content);

        return $content;
    }
51029
private function extractSignedContent($content)
    {
        $signature = substr($content, -40);

        if (substr($content, -43, 3) == self::VALUE_SEPARATOR . '_=' &&
            $signature == sha1(substr($content, 0, -40) . SettingsPiwik::getSalt())
        ) {
            // strip trailing: VALUE_SEPARATOR '_=' signature"
            return substr($content, 0, -43);
        }

        return false;
    }
1313010
protected function sanitize_text( $text ) {
		// not fancy
		$text = strip_tags( $text );
		$text = esc_html( $text );
		$text = trim( $text );

		return $text;
	}
1364588
public function extractContent($content)
    {
        $regex = '~^('
            . '---'                                  // $matches[1] start separator
            . "){1}[\r\n|\n]*(.*?)[\r\n|\n]+("       // $matches[2] front matter
            . '---'                                  // $matches[3] end separator
            . "){1}[\r\n|\n]*(.*)$~s";               // $matches[4] document content

        return preg_match($regex, $content, $matches) === 1 ? ltrim($matches[4]) : $content;
    }
551431
public function parseContent($content)
    {
        $cto = $this->getContentTypeObject();
        if (!empty($cto)) {
            return $cto->parseContent($content);
        } else {
            return $content;
        }
    }
563065
protected function htmlContent($content)
    {
        try {

            $this->getMbAudit()->setResponseType('html');

            if ($content instanceof \Exception) {

                throw $content;

            } elseif ($content instanceof \SplFileInfo && !$this->getMbRequest()->isBlogAdmin()) {

                $this->downloadFile($content);

            } elseif (!is_string($content) && !$content instanceof Renderable) {

                $this->getMbAudit()->setResponseType('debug');
                $this->getMbAudit()->setResponseData($content);

                ob_start();
                (new Dumper)->dump($content);
                $this->original = ob_get_contents();
                ob_end_clean();

            } else {

                $this->getMbAudit()->setResponseData($content);
                $this->original = $content;

            }

            parent::setContent($this->original);

        } catch (\Exception $e) {

            $this->getMbAudit()->setResponseData($e->getMessage());

            if ($this->getMbRequest()->isBlogAdmin()) {
                $this->adminNotice($e->getMessage(), 'error');
            } else {
                $this->original = "<strong>Erro:</strong> {$e->getMessage()}<br>";
            }

            parent::setContent($this->original);
        }
    }
676297
protected function cleanText($text)
    {
        $strippedText = strip_tags($text);
        $strippedText = htmlentities($strippedText, ENT_QUOTES, $this->getCharset(), FALSE);
        return html_entity_decode($strippedText, ENT_QUOTES, $this->getCharset());
    }
1164478
protected function removeHtml($text)
    {
        // Remove HTML markup
        $result = strip_tags($text);

        // Decode HTML entities
        $result = trim(html_entity_decode($result, ENT_QUOTES));

        return $result;
    }
1227489
public function getResponse($content = '')
    {
        //transform content by content type
        if ($this->isJsonRequest()) {
            if ($content instanceof Response\JsonResponse) {
                $content = json_decode($content->getBody());
            } elseif (!is_array($content)) {
                $content = [$content];
            }
        } else {
            if (is_array($content)) {
                $content = implode('', $content);
            } elseif ($content instanceof ResponseInterface) {
                $content = $content->getBody()->__toString();
            }
        }

        if (!$this->getContainer()->has(ResponseInterface::class)) {
            if ($this->isCli()) {
                $class = Response\TextResponse::class;
            } elseif ($this->isJsonRequest()) {
                $class = Response\JsonResponse::class;
            } else {
                $class = Response\HtmlResponse::class;
            }
            $this->getContainer()->add(ResponseInterface::class, $class);
        }

        /** @var ResponseInterface $response */
        $response = $this->validateContract($this->getContainer()->get(ResponseInterface::class, [$content]),
            ResponseInterface::class);

        //inject request content type
        $request = $this->getRequest();

        $contentTypeKey = 'content-type';
        foreach ($request->getHeader($contentTypeKey) as $contentType) {
            $response = $response->withHeader($contentTypeKey, $contentType);
        }

        return $response;
    }
430072
private static function sanitize($data)
    {
        $data = trim($data);
        $data = stripslashes($data);
        $data = htmlspecialchars($data);
        return $data;
    }
915328
public static function encodeHtml($content)
    {
        $content = self::unicodeToShortcode($content);
        $content = self::shortcodeToEntities($content);

        return $content;
    }
674529
public static function fromString(string $content)
    {
        $arr = \json_decode($content, JSON_PRETTY_PRINT);
        $arr = attrToArray($arr);
        return fromArray($arr);
    }
151846
public static function xss_entity_decode($content)
    {
        $callback = function($matches) { return chr(hexdec($matches[1])); };

        $out = html_entity_decode(html_entity_decode($content));
        $out = trim(preg_replace('/(^<!--|-->$)/', '', trim($out)));
        $out = preg_replace_callback('/\\\([0-9a-f]{2,6})\s*/i', $callback, $out);
        $out = preg_replace('/\\\([^0-9a-f])/i', '\\1', $out);
        $out = preg_replace('#/\*.*\*/#Ums', '', $out);
        $out = strip_tags($out);

        return $out;
    }