roundcubemail/plugins/managesieve/lib/Roundcube/rcube_sieve_script.php
static function escape_string($str)
    {
        if (is_array($str) && count($str) > 1) {
            foreach ($str as $idx => $val)
                $str[$idx] = self::escape_string($val);

            return '[' . implode(',', $str) . ']';
        }
        else if (is_array($str)) {
            $str = array_pop($str);
        }

        // multi-line string
        if (preg_match('/[\r\n\0]/', $str)) {
            return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str));
        }
        // quoted-string
        else {
            return '"' . addcslashes($str, '\\"') . '"';
        }
    }
static function escape_string($str)
    {
        if (is_array($str) && count($str) > 1) {
            foreach ($str as $idx => $val)
                $str[$idx] = self::escape_string($val);

            return '[' . implode(',', $str) . ']';
        }
        else if (is_array($str)) {
            $str = array_pop($str);
        }

        // multi-line string
        if (preg_match('/[\r\n\0]/', $str)) {
            return sprintf("text:\n%s\n.\n", self::escape_multiline_string($str));
        }
        // quoted-string
        else {
            return '"' . addcslashes($str, '\\"') . '"';
        }
    }
static function escape_string ( $ str ) { if ( is_array ( $ str ) && count ( $ str ) > 1 ) { foreach ( $ str as $ idx => $ val ) $ str [ $ idx ] = self :: escape_string ( $ val ) ; return '[' . implode ( ',' , $ str ) . ']' ; } else if ( is_array ( $ str ) ) { $ str = array_pop ( $ str ) ; } // multi-line string if ( preg_match ( '/[\r\n\0]/' , $ str ) ) { return sprintf ( "text:\n%s\n.\n" , self :: escape_multiline_string ( $ str ) ) ; } // quoted-string else { return '"' . addcslashes ( $ str , '\\"' ) . '"' ; } }
Escape special chars into quoted string value or multi-line string
or list of strings

@param string $str Text or array (list) of strings

@return string Result text
Escape special chars into quoted string value or multi - line string or list of strings