FML/Script/Builder.php
public static function escapeText($text, $addApostrophes = true)
    {
        $dangers      = array('\\', '"', "\n");
        $replacements = array('\\\\', '\\"', '\\n');
        $escapedText  = str_ireplace($dangers, $replacements, $text);
        if ($addApostrophes) {
            $escapedText = '"' . $escapedText . '"';
        }
        return $escapedText;
    }
public static function escapeText($text, $addApostrophes = true)
    {
        $dangers      = array('\\', '"', "\n");
        $replacements = array('\\\\', '\\"', '\\n');
        $escapedText  = str_ireplace($dangers, $replacements, $text);
        if ($addApostrophes) {
            $escapedText = '"' . $escapedText . '"';
        }
        return $escapedText;
    }
public static function escapeText ( $ text , $ addApostrophes = true ) { $ dangers = array ( '\\' , '"' , "\n" ) ; $ replacements = array ( '\\\\' , '\\"' , '\\n' ) ; $ escapedText = str_ireplace ( $ dangers , $ replacements , $ text ) ; if ( $ addApostrophes ) { $ escapedText = '"' . $ escapedText . '"' ; } return $ escapedText ; }
Escape dangerous characters in the given text

@api
@param string $text           Text to escape
@param bool   $addApostrophes (optional) Add apostrophes before and after the text
@return string
Escape dangerous characters in the given text