Ticket #222: view.patch

File view.patch, 1.5 kB (added by armen, 14 months ago)
  • system/config/view.php

     
     1<?php defined('SYSPATH') or die('No direct script access.'); 
     2/* 
     3 * File: View 
     4 * 
     5 * Options: 
     6 *  allowed_types 
     7 */ 
     8$config = array 
     9( 
     10        'allowed_types' => array('gif', 'jpeg', 'css', 'js', 'tiff', 'tif', 'swf') 
     11); 
  • system/libraries/View.php

     
    2525         */ 
    2626        public function __construct($name, $data = NULL) 
    2727        { 
    28                 if (preg_match('/\.(?:gif|jpe?g|png|css|js|tiff?|swf)$/Di', $name, $type)) 
     28                $type = substr(strrchr($name, '.'), 1); 
     29                 
     30                if (in_array($type, Config::item('view.allowed_types'))) 
    2931                { 
    30                         $type = substr($type[0], 1); 
    31  
    3232                        $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); 
    3333                        $this->kohana_filetype = current(Config::item('mimes.'.$type)); 
    3434 
     
    3737                } 
    3838                else 
    3939                { 
    40                         $this->kohana_filename = Kohana::find_file('views', $name, TRUE); 
    41                         $this->kohana_filetype = EXT; 
     40                        $this->kohana_filename = Kohana::find_file('views', $name, TRUE, $type); 
     41                        $this->kohana_filetype = ($type == FALSE) ? EXT : $type; 
    4242                } 
    4343 
    4444                if (is_array($data) AND ! empty($data)) 
     
    178178                return $output; 
    179179        } 
    180180 
    181 } // End View Class 
    182  No newline at end of file 
     181} // End View Class