Changeset 488
- Timestamp:
- Aug 26, 2014 11:50:45 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Upload.inc.php
r485 r488 474 474 475 475 /** 476 * Removes unsafe characters from file name.476 * Removes non-latin characters from file name, using htmlentities to convert known weirdos into regular squares. 477 477 * 478 478 * @access public … … 482 482 public function cleanFileName($file_name) 483 483 { 484 $bad = 'áéÃóúà ÚìòùÀëïöÌÃÃÃÃÃÃÃÃÃÃÃÃÃÃÃâêîÎûÃÃÃÃÃñçÃ'; 485 $good = 'aeiouaeiouaeiouAEIOUAEIOUAEIOUaeiouAEIOUncC'; 486 $file_name = trim($file_name); 487 $file_name = strtr($file_name, $bad, $good); 488 $file_name = preg_replace('/[^-\w.,~_=+()@]+/i', '_', $file_name); 489 $file_name = mb_substr($file_name, 0, 250); 490 return $file_name; 484 $file_name = preg_replace(array( 485 '/&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml|caron);/ui', 486 '/&(?:amp);/ui', 487 '/[&;]+/u', 488 '/[^a-zA-Z0-9()@._=+-]+/u', 489 '/^_+|_+$/u' 490 ), array( 491 '$1', 492 'and', 493 '', 494 '_', 495 '' 496 ), htmlentities($file_name, ENT_NOQUOTES | ENT_IGNORE, 'UTF-8')); 497 return mb_substr($file_name, 0, 250); 491 498 } 492 499
Note: See TracChangeset
for help on using the changeset viewer.