src/variables/TypogrifyVariable.php
private function normalizeText($text): string
    {
/* @TODO: try to resolve at a later date; Twig's `| raw` just returns a string, not `Markup` so we can't use that as a check
        if ($text instanceof Markup) {
            // Either came from a Redactor field (or the like) or they manually added a |raw tag. We can trust it
            $text = (string)$text;
        } else {
            // We don't trust it, so escape any HTML
            $twig = Craft::$app->view->twig;
            try {
                $text = twig_escape_filter($twig, $text);
            } catch (\Twig_Error_Runtime $e) {
                $error = $e->getMessage();
                Craft::error($error, __METHOD__);
                // We don't want unescaped text slipping through, so set the text to the error message
                $text = $error;
            }
        }
*/
        // If it's null or otherwise empty, just return an empty string
        if (empty($text)) {
            $text = '';
        }
        $text = (string)$text;

        $settings = Typogrify::$plugin->getSettings();

        if ($settings['default_escape'] === true) {
            $twig = Craft::$app->view->twig;
            $text = twig_escape_filter($twig, $text);
        }

        return $text;
    }
private function normalizeText($text): string
    {
/* @TODO: try to resolve at a later date; Twig's `| raw` just returns a string, not `Markup` so we can't use that as a check
        if ($text instanceof Markup) {
            // Either came from a Redactor field (or the like) or they manually added a |raw tag. We can trust it
            $text = (string)$text;
        } else {
            // We don't trust it, so escape any HTML
            $twig = Craft::$app->view->twig;
            try {
                $text = twig_escape_filter($twig, $text);
            } catch (\Twig_Error_Runtime $e) {
                $error = $e->getMessage();
                Craft::error($error, __METHOD__);
                // We don't want unescaped text slipping through, so set the text to the error message
                $text = $error;
            }
        }
*/
        // If it's null or otherwise empty, just return an empty string
        if (empty($text)) {
            $text = '';
        }
        $text = (string)$text;

        $settings = Typogrify::$plugin->getSettings();

        if ($settings['default_escape'] === true) {
            $twig = Craft::$app->view->twig;
            $text = twig_escape_filter($twig, $text);
        }

        return $text;
    }
private function normalizeText ( $ text ) : string { /* @TODO: try to resolve at a later date; Twig's `| raw` just returns a string, not `Markup` so we can't use that as a check
        if ($text instanceof Markup) {
            // Either came from a Redactor field (or the like) or they manually added a |raw tag. We can trust it
            $text = (string)$text;
        } else {
            // We don't trust it, so escape any HTML
            $twig = Craft::$app->view->twig;
            try {
                $text = twig_escape_filter($twig, $text);
            } catch (\Twig_Error_Runtime $e) {
                $error = $e->getMessage();
                Craft::error($error, __METHOD__);
                // We don't want unescaped text slipping through, so set the text to the error message
                $text = $error;
            }
        }
*/ // If it's null or otherwise empty, just return an empty string if ( empty ( $ text ) ) { $ text = '' ; } $ text = ( string ) $ text ; $ settings = Typogrify :: $ plugin -> getSettings ( ) ; if ( $ settings [ 'default_escape' ] === true ) { $ twig = Craft :: $ app -> view -> twig ; $ text = twig_escape_filter ( $ twig , $ text ) ; } return $ text ; }
Normalize the passed in text to ensure that untrusted strings are escaped

@param $text

@return string
Normalize the passed in text to ensure that untrusted strings are escaped