Welcome Guest, Not a member yet? Register   Sign In
Loop not needed in Upload library
#1

[eluser]Alex.[/eluser]
Lines 672 - 716 of system/libraries/Upload.php
Code:
/**
     * Clean the file name for security
     *
     * @access    public
     * @param    string
     * @return    string
     */        
    function clean_file_name($filename)
    {
        $bad = array(
                        "<!--",
                        "-->",
                        "'",
                        "<",
                        ">",
                        '"',
                        '&',
                        '$',
                        '=',
                        ';',
                        '?',
                        '/',
                        " ",
                        """,
                        "<",        // <
                        "%3c",     // <
                        ">",         // >
                        "",         // >
                        "(",         // (
                        ")",         // )
                        "%28",     // (
                        "&",         // &
                        "$",         // $
                        "?",         // ?
                        ";",         // ;
                        "="        // =
                    );
                    
        foreach ($bad as $val)
        {
            $filename = str_replace($val, '', $filename);
        }

        return stripslashes($filename);
    }
Would it not be better to just pass the $bad variable as the first parameter like so?:
Code:
str_replace($bad, '', $filename);
Thus avoiding the need for the loop.


Messages In This Thread
Loop not needed in Upload library - by El Forum - 07-12-2008, 02:41 PM
Loop not needed in Upload library - by El Forum - 07-12-2008, 03:59 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 12:04 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 01:37 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 01:47 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 02:25 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 02:38 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 02:40 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 02:42 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 02:59 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 03:14 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 03:45 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 03:47 PM
Loop not needed in Upload library - by El Forum - 07-13-2008, 04:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB