Changeset 530


Ignore:
Timestamp:
Jun 25, 2015 10:33:35 PM (9 years ago)
Author:
anonymous
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Upload.inc.php

    r523 r530  
    502502        }
    503503    }
     504
     505    /**
     506     * Remove unsafe characters from filename.
     507     * While this function has been moved to Utilities.inc.php, it should remain here for backwards compatibility.
     508     *
     509     * @access  public
     510     * @param   string  $file_name  A name of a file.
     511     * @return  string              The same name, but cleaned.
     512     */
     513    public function cleanFileName($file_name)
     514    {
     515        $app =& App::getInstance();
     516
     517        $file_name = preg_replace(array(
     518            '/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/ui',
     519            '/&(?:amp);/ui',
     520            '/[&;]+/u',
     521            '/[^a-zA-Z0-9()@._=+-]+/u',
     522            '/^_+|_+$/u'
     523        ), array(
     524            '$1',
     525            'and',
     526            '',
     527            '_',
     528            ''
     529        ), htmlentities($file_name, ENT_NOQUOTES | ENT_IGNORE, $app->getParam('character_set')));
     530        return mb_substr($file_name, 0, 250);
     531    }
    504532}
    505533
Note: See TracChangeset for help on using the changeset viewer.