Ticket #677 (closed Bug: worksforme)

Opened 7 years ago

Last modified 6 years ago

Char no usable in url can be use in filemanager (like é or ù)

Reported by: sblanc74@… Owned by:
Priority: Normal Milestone:
Component: File Browser Version:
Keywords: SF Pending Cc:

Description

Hi,

The file manager accept file or folder with char who can't be read by a browser like "Canyon du Crêt de la Neige.jpg" so this file or folder can't be found on the web.

i modify some functions, CreateFolder() and FileUpload (), in commands.php file to convert this "bad" char into readable char

function CreateFolder( $resourceType, $currentFolder )
{
$sErrorNumber = '0' ;
$sErrorMsg = '' ;

if ( isset( $_GET['NewFolderName'] ) )
{
$sNewFolderName = $_GET['NewFolderName'] ;
// BEGIN OF CHANGE
$sNewFolderName= strtr
($sNewFolderName,"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöø
ÈÉÊËèéêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ","aaaaaaaaaaaaooooo
oooooooeeeeeeeecciiiiiiiiuuuuuuuuynn");
$sNewFolderName = preg_replace('([^_a-zA-Z0-9])', '_',
$sNewFolderName )."_";
$sNewFolderName = eregi_replace ('^(_)*', '',
$sNewFolderName);
$sNewFolderName = eregi_replace ('(_)*$', '',
$sNewFolderName);
$sNewFolderName = eregi_replace ('(_){2,10}', '_',
$sNewFolderName);

// END OF CHANGE
if ( strpos( $sNewFolderName, '..' ) !== FALSE )
$sErrorNumber = '102' ; // Invalid folder name.
else
{
function FileUpload( $resourceType, $currentFolder )
{
$sErrorNumber = '0' ;
$sFileName = '' ;

if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES
['NewFile']['tmp_name'] ) )
{
$oFile = $_FILES['NewFile'] ;

// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder( $resourceType,
$currentFolder ) ;

// Get the uploaded file name.
$sFileName = $oFile['name'] ;
$sOriginalFileName = $sFileName ;
$sExtension = substr( $sFileName, ( strrpos
($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;

global $Config ;

$arAllowed = $Config['AllowedExtensions']
[$resourceType] ;
$arDenied = $Config['DeniedExtensions']
[$resourceType] ;

if ( ( count($arAllowed) == 0 || in_array( $sExtension,
$arAllowed ) ) && ( count($arDenied) == 0 || !in_array(
$sExtension, $arDenied ) ) )
{
$iCounter = 0 ;

while ( true )
{
// BEGIN OF CHANGE
$sFileName= strtr
($sFileName,"ÀÁÂÃÄÅàáâãäåÒÓÔÕÖØòóôõöøÈÉÊËè
éêëÇçÌÍÎÏìíîïÙÚÛÜùúûüÿÑñ","aaaaaaaaaaaaooooooooooo
oeeeeeeeecciiiiiiiiuuuuuuuuynn");
$sFileName = preg_replace('([^_a-zA-Z0-9\.])', '_',
$sFileName )."_";
$sFileName = eregi_replace ('^(_)*', '', $sFileName);
$sFileName = eregi_replace ('(_)*$', '', $sFileName);
$sFileName = eregi_replace ('(_){2,10}', '_',
$sFileName);

// END OF CHANGE
$sFilePath = $sServerDir . $sFileName ;


if ( is_file( $sFilePath ) )

Regards Sylvain B.


Moved from SF:
http://sourceforge.net/tracker/index.php?func=detail&aid=1325453&group_id=75348&atid=543653

Change History

comment:1 Changed 7 years ago by martinkou

  • Reporter changed from martinkou to sblanc74@…

comment:2 Changed 7 years ago by alfonsoml

  • Keywords Pending added
  • Component changed from General to File Browser

The current filemanager should encode properly those characters. Could you please try it?

comment:3 Changed 6 years ago by alfonsoml

  • Status changed from new to closed
  • Resolution set to worksforme

Expired

Note: See TracTickets for help on using tickets.
© 2003 – 2012 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy