• Resolved fra_casula

    (@fra_casula)


    Hi there,

    I believe I’ve found and fixed a bug that is affecting this plugin.

    ‘lib/functions.php/’ line 538 and 543

    The $upload_dir['basedir'] is not being expanded with realpath() whilst the $cur_local_file is. This makes the str_replace call fail when the upload folder is symlinked.

    Old code:

    foreach ($files as $fileinfo) {
    		$the_file = $fileinfo->getRealPath();
    		$file_path = pathinfo($the_file);
    	    if (!is_dir($the_file)) {
    	    	if (isset($_SESSION['cdn']->api_settings->files_to_ignore)) {
    	    		// File extensions ignored
    	    		$ignore_files = explode(",", $_SESSION['cdn']->api_settings->files_to_ignore);
    		    	if (!in_array($file_path['extension'], $ignore_files)) {
    		    		$cur_local_file = $fileinfo->getRealPath();
    		    		$local_files[$i++] = array('fn' => trim(str_replace($upload_dir['basedir'], '', $cur_local_file), '/'), 'fs' => filesize($cur_local_file));
    		    	}
    	    	} else {
    		    	// No file extensions ignored
    		    	$cur_local_file = $fileinfo->getRealPath();
    		    	$local_files[$i++] = array('fn' => trim(str_replace($upload_dir['basedir'], '', $cur_local_file), '/'), 'fs' => filesize($cur_local_file));
    	    	}
    	    }
    	}

    New code:

    foreach ($files as $fileinfo) {
    		$the_file = $fileinfo->getRealPath();
    		$file_path = pathinfo($the_file);
    	    if (!is_dir($the_file)) {
    		    $upload_base_dir = realpath($upload_dir['basedir']);
    
    	    	if (isset($_SESSION['cdn']->api_settings->files_to_ignore)) {
    	    		// File extensions ignored
    	    		$ignore_files = explode(",", $_SESSION['cdn']->api_settings->files_to_ignore);
    		    	if (!in_array($file_path['extension'], $ignore_files)) {
    		    		$cur_local_file = $fileinfo->getRealPath();
    		    		$local_files[$i++] = array('fn' => trim(str_replace($upload_base_dir, '', $cur_local_file), '/'), 'fs' => filesize($cur_local_file));
    		    	}
    	    	} else {
    		    	// No file extensions ignored
    		    	$cur_local_file = $fileinfo->getRealPath();
    		    	$local_files[$i++] = array('fn' => trim(str_replace($upload_base_dir, '', $cur_local_file), '/'), 'fs' => filesize($cur_local_file));
    	    	}
    	    }
    	}

    https://ww.wp.xz.cn/plugins/rackspace-cloud-files-cdn/

Viewing 1 replies (of 1 total)
  • Plugin Author paypromedia

    (@paypromedia)

    Thank you very much! I will get this code implemented as soon as possible.

Viewing 1 replies (of 1 total)

The topic ‘Symlink bug’ is closed to new replies.